4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GSAP ScrollToPluginを利用してwebpackのproductionモードでbuildとエラーがでる

Last updated at Posted at 2019-09-27

webpackでGSAP ScrollToPluginを利用した際にproductionモードでbuildした場合にエラーが発生。
(developmentモードでは正しく機能する)


import { TimelineMax, ScrollToPlugin } from 'gsap/all';

中略
TweenMax.to(window, 0.4, {
  ease: Power1.easeOut,
  scrollTo: {
    y: 0,
    autoKill: false
  }
});

このようなコードをproductionモードでbuildすると、下記の様なエラーが発生し機能しない。

Failed to execute 'scrollTo' on 'Window': parameter 1 ('options') is not an object.

#解決策
const scrollPlugin = ScrollToPlugin;
を追加することで解決。


import { TimelineMax, ScrollToPlugin } from 'gsap/all';
const scrollPlugin = ScrollToPlugin;

中略
TweenMax.to(window, 0.4, {
  ease: Power1.easeOut,
  scrollTo: {
    y: 0,
    autoKill: false
  }
});

4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?