如何将GSAP库导入Ionic项目。只使用 npm install gsap 在我通过
导入时不起作用import { TweenMax, TimelineMax} from "gsap";
我使用打字稿。 感谢
答案 0 :(得分:2)
你不需要打字。我已在几个项目中使用它(所有这些都是Typescript):
assets/javascripts
将您的文件包含在src/index.html
文件中,如下所示:
<script src="assets/javascripts/TweenMax.min.js"></script>
在导入之后,像这样声明GSAP对象(在您将使用它们的所有视图中):
/*
Normal imports here..
*/
import { LoginPage } from "../login/login";
declare var TimelineMax: any;
declare var TweenMax: any;
declare var Power1: any;
@Component({
selector: 'page-profile',
templateUrl: 'profile.html',
providers: [Data, Api, DatePipe]
})
export class ProfilePage {
...
使用正常:
...
ionViewDidLoad(){
TweenMax.from(".logo", .5, {
opacity: 0,
y: -72,
ease: Power1.easeOut
});
}
...
答案 1 :(得分:1)
典型导入
import {TweenMax, Power2, TimelineLite} from "gsap";
获取TweenMax
import Draggable from "gsap/Draggable";
import ScrollToPlugin from "gsap/ScrollToPlugin";
更多信息 -