GSAP in Ionic project

眉间皱痕 提交于 2019-12-24 06:44:24

问题


How can Import the GSAP library into an Ionic project. Just using npm install gsap don't work when I import through

import { TweenMax, TimelineMax} from "gsap";

I use typescript. Thanks


回答1:


You don't need Typings for it. I've used it in several projects (all of them Typescript):

  1. Put the GSAP libraries you want to use in assets/javascripts
  2. Include your file in your src/index.html file like this:

    <script src="assets/javascripts/TweenMax.min.js"></script>

  3. Right after your imports, declare the GSAP objects like this (in all the views you will be using them):

    /*
      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 {
      ...
    
  4. Use like normal:

    ...
    ionViewDidLoad(){
      TweenMax.from(".logo", .5, { 
        opacity: 0,
        y: -72,
        ease:  Power1.easeOut
      });
    }
    ...
    



回答2:


Typical import

import {TweenMax, Power2, TimelineLite} from "gsap";

Get the parts that aren't included inside TweenMax

import Draggable from "gsap/Draggable";
import ScrollToPlugin from "gsap/ScrollToPlugin";

For More information-

https://www.npmjs.com/package/gsap#npm



来源:https://stackoverflow.com/questions/45682344/gsap-in-ionic-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!