Jump to content
GreenSock

fatnjazzy

Using with Angular5/6

Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

I want to using this amazing framework angular,

Can someone please post a https://stackblitz.com example of how to use with angular? (including typing if possible.). 

Thanks

Link to comment
Share on other sites

Thanks, the auto complete should work? because it isn't i think.

 

Link to comment
Share on other sites

Sorry I am not sure, @OSUblake can comment on that. Recently he mentioned types are incomplete, I am not aware of any workaround that.

 

 

  • Like 4
Link to comment
Share on other sites

Thanks, Ill wait for his response.

 

Also, im importing 

import * as Draggable from "gsap/Draggable";

 

and im getting this error:

 

Quote

AppComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: gsap_Draggable__WEBPACK_IMPORTED_MODULE_1__.create is not a function
    at AppComponent.push../src/app/app.component.ts.AppComponent.ngOnInit (app.component.ts:52)
    at checkAndUpdateDirectiveInline (core.js:9251)
    at checkAndUpdateNodeInline (core.js:10515)
    at checkAndUpdateNode (core.js:10477)
    at debugCheckAndUpdateNode (core.js:11110)
    at debugCheckDirectivesFn (core.js:11070)
    at Object.eval [as updateDirectives] (AppComponent_Host.ngfactory.js? [sm]:1)
    at Object.debugUpdateDirectives [as updateDirectives] (core.js:11062)
    at checkAndUpdateView (core.js:10459)
    at callWithDebugContext (core.js:11352)

 

Link to comment
Share on other sites

7 hours ago, fatnjazzy said:

Thanks, Ill wait for his response.

 

Also, im importing 

import * as Draggable from "gsap/Draggable";

 

 

That works when importing Draggable with TypeScript with older versions of GSAP or when using the umd versions. If you're using the latest version of GSAP (2.0.1), try importing like this.

import Draggable from "gsap/Draggable";

 

And there won't be any auto-complete for Draggable. If you get errors, the simplest way to silence is to add this to your code.

declare var Draggable;

 

  • Like 4
Link to comment
Share on other sites

Hi, @OSUblake  Thank you.

Im using the latest version. 

changed it to:

import Draggable from "gsap/Draggable";

declare var Draggable;

Still I get the same error from above.

Thanks

Link to comment
Share on other sites

  • 1 month later...

I had the same issue in Angular 6 with WebStorm showing that the 'gsap/Draggable' didn't exist. Drove me nuts. But after visiting here I just ran it anyway and the application works fine - doesn't throw an errors. 

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

To use Draggable with Angular 6 you might need to install types from green sock

 

npm install --save-dev @types/greensock

 

And in component import Draggable as 

 

import { Draggable } from "gsap/all";
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×