Share Posted November 8, 2018 Hi, I have been working on a scrollTo feature using ScrollToPlugin. It's working all fine on local environment, however after a production build in Angular (7.0.1 to be exact) tween throws famous scrollTo error: Failed to execute 'scrollTo' on 'Window': parameter 1 ('options') is not an object. This is how I import GSAP modules: import { TweenMax, Power3 } from 'gsap' import 'gsap/ScrollToPlugin' console.log(com.greensock.plugins.ScrollToPlugin.version) // 1.9.1 console.log(com.greensock.TweenMax.version) // 2.0.2 And this is how I tween: TweenMax.to(window, duration, { scrollTo: y, ease: Power3.easeInOut }) buildOptimizer for Angular is set to false. Import from 'gsap/all' neither works in a production build. What am I missing? SOLUTION: Angular client is tree shaking so I had to reference ScrollToPlugin just after the import. Credits to @Rodrigo import { TweenMax, Power3, ScrollToPlugin } from 'gsap/all' const plugins = [ ScrollToPlugin ] Angular: 7.0.1 Gsap: 2.0.2 Link to comment Share on other sites More sharing options...
Share Posted November 8, 2018 Hi, I'm not very familiar with how the latest versions of Angular are bundled, so I'll guess that it uses webpack and perhaps you're bundling with a create app type-CLI. If that's the case, the culprit could be tree shaking. Please read this: https://greensock.com/docs/NPMUsage More specifically the tree shaking part (just scroll down a bit) and let us know how it goes. Happy Tweening!! 4 1 Link to comment Share on other sites More sharing options...
Author Share Posted November 8, 2018 7 minutes ago, Rodrigo said: Hi, I'm not very familiar with how the latest versions of Angular are bundled, so I'll guess that it uses webpack and perhaps you're bundling with a create app type-CLI. If that's the case, the culprit could be tree shaking. Please read this: https://greensock.com/docs/NPMUsage More specifically the tree shaking part (just scroll down a bit) and let us know how it goes. Happy Tweening!! That was the thing, thank you I will update the post with the solution, thanks! 3 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now