NPM中的GSAP动画如何与Angular组件结合?
Hello, GSAP!
`,
styles: [`
div {
width: 100px;
height: 100px;
background-color: red;
transition: transform 0.5s;
}
`]
})
export class AnimationComponent implements OnInit {
style = {};
constructor() {}
ngOnInit() {
this.animate();
}
animate() {
gsap.to(this.style, {
duration: 1,
transform: 'translateX(100px)'
});
}
}
```
3. 使用动画组件
在父组件中,引入并使用动画组件:
```typescript
import { Component } from '@angular/core';
import { AnimationComponent } from './animation.component';
@Component({
selector: 'app-root',
template: `猜你喜欢:应用故障定位