ScrollMagic - Uncaught ReferenceError: ScrollScene is not defined
ScrollMagic - Uncaught ReferenceError: ScrollScene is not defined
为什么最新版本的ScrollMagic会出现下面这个错误?
Uncaught ReferenceError: ScrollScene is not defined
这是我的测试代码 guide:
$(function() {
// Init Controller
var scrollMagicController = new ScrollMagic();
// Create Animation for 0.5s
var tween = TweenMax.to('#animation', 0.5, {
backgroundColor: 'rgb(255, 39, 46)',
scale: 7,
rotation: 360
});
// Create the Scene and trigger when visible with ScrollMagic
var scene1 = new ScrollScene({
triggerElement: '#scene',
offset: 150 /* offset the trigger 150px below #scene's top */
})
.setTween(tween)
.addTo(scrollMagicController);
// Add debug indicators fixed on right side
scene1.addIndicators();
});
如果我使用的是最新版本:
<script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/debug.addIndicators.min.js"></script>
完整错误:
Uncaught ReferenceError: ScrollScene is not defined
at HTMLDocument.<anonymous> (basic.php:66)
at c (jquery.min.js:3)
at Object.fireWith [as resolveWith] (jquery.min.js:3)
at Function.ready (jquery.min.js:3)
at HTMLDocument.H (jquery.min.js:3)
但是如果我使用这个版本(我猜是旧版本)并且它工作正常:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/1.3.0/jquery.scrollmagic.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/1.3.0/jquery.scrollmagic.debug.js"></script>
我的HTML:
<div class="post">
<span class="glyphicon glyphicon-grain"> </span>
<h2> Lorem ipsum dolor sit amet, consetetur sadipscing elitr</h2>
</div>
<div class="post" id="scene">
<span class="glyphicon glyphicon-lamp" id="animation"> </span>
<h2> Lorem ipsum dolor sit amet, consetetur sadipscing elitr</h2>
</div>
有什么想法吗?
编辑:
如果我使用 github 中的指南:
// Init Controller
var scrollMagicController = new ScrollMagic.Controller();
// Create Animation for 0.5s
var tween = TweenMax.to('#animation', 0.5, {
backgroundColor: 'rgb(255, 39, 46)',
scale: 7,
rotation: 360
});
// Create the Scene and trigger when visible with ScrollMagic
var scene1 = new ScrollMagic.Scene({
triggerElement: '#scene',
offset: 150 /* offset the trigger 150px below #scene's top */
})janpaepke-ScrollMagic/scrollmagic/minified/plugins/debug.addIndicators.min.js
.setTween(tween)
.addTo(scrollMagicController);
// Add debug indicators fixed on right side
scene1.addIndicators();
我会得到这个错误:
Uncaught TypeError: (intermediate value).setTween is not a function
at HTMLDocument.<anonymous> (basic.php:70)
at c (jquery.min.js:3)
at Object.fireWith [as resolveWith] (jquery.min.js:3)
at Function.ready (jquery.min.js:3)
at HTMLDocument.H (jquery.min.js:3)
为什么!????他们的文档太糟糕了!
编辑 2:
所以我用的是下载版:
<script src="libs/janpaepke-ScrollMagic/js/lib/greensock/TweenMax.min.js"></script>
<script src="libs/janpaepke-ScrollMagic/scrollmagic/minified/plugins/animation.gsap.min.js"></script>
<!-- should be replaced with minified version when development is finished -->
<script src="libs/janpaepke-ScrollMagic/scrollmagic/minified/plugins/jquery.ScrollMagic.min.js"></script>
<!-- should be removed when development is finished -->
<script src="libs/janpaepke-ScrollMagic/scrollmagic/minified/plugins/debug.addIndicators.min.js"></script>
我收到更多错误:
jquery.ScrollMagic.min.js:2 Uncaught TypeError: Cannot read property '_util' of undefined
at jquery.ScrollMagic.min.js:2
at jquery.ScrollMagic.min.js:2
at jquery.ScrollMagic.min.js:2
(anonymous) @ jquery.ScrollMagic.min.js:2
(anonymous) @ jquery.ScrollMagic.min.js:2
(anonymous) @ jquery.ScrollMagic.min.js:2
debug.addIndicators.min.js:2 Uncaught TypeError: Cannot read property '_util' of undefined
at debug.addIndicators.min.js:2
at debug.addIndicators.min.js:2
at debug.addIndicators.min.js:2
(anonymous) @ debug.addIndicators.min.js:2
(anonymous) @ debug.addIndicators.min.js:2
(anonymous) @ debug.addIndicators.min.js:2
basic.php:65 Uncaught ReferenceError: ScrollMagic is not defined
at HTMLDocument.<anonymous> (basic.php:65)
at c (jquery.min.js:3)
at Object.fireWith [as resolveWith] (jquery.min.js:3)
at Function.ready (jquery.min.js:3)
at HTMLDocument.H (jquery.min.js:3)
文件名和文件夹结构完全是一团糟。令人困惑和不一致!
您还必须导入 gsap 插件。检查 scrollmagic 文件夹。
animation.gsap.min.js
尝试使用
new $.ScrollMagic.Scene
而不是
new ScrollMagic.Scene
应该有帮助。
如果您使用 1.3.0 版本,它可以在没有“$.”的情况下工作
为什么最新版本的ScrollMagic会出现下面这个错误?
Uncaught ReferenceError: ScrollScene is not defined
这是我的测试代码 guide:
$(function() {
// Init Controller
var scrollMagicController = new ScrollMagic();
// Create Animation for 0.5s
var tween = TweenMax.to('#animation', 0.5, {
backgroundColor: 'rgb(255, 39, 46)',
scale: 7,
rotation: 360
});
// Create the Scene and trigger when visible with ScrollMagic
var scene1 = new ScrollScene({
triggerElement: '#scene',
offset: 150 /* offset the trigger 150px below #scene's top */
})
.setTween(tween)
.addTo(scrollMagicController);
// Add debug indicators fixed on right side
scene1.addIndicators();
});
如果我使用的是最新版本:
<script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/ScrollMagic.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/ScrollMagic/2.0.5/plugins/debug.addIndicators.min.js"></script>
完整错误:
Uncaught ReferenceError: ScrollScene is not defined
at HTMLDocument.<anonymous> (basic.php:66)
at c (jquery.min.js:3)
at Object.fireWith [as resolveWith] (jquery.min.js:3)
at Function.ready (jquery.min.js:3)
at HTMLDocument.H (jquery.min.js:3)
但是如果我使用这个版本(我猜是旧版本)并且它工作正常:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/1.3.0/jquery.scrollmagic.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ScrollMagic/1.3.0/jquery.scrollmagic.debug.js"></script>
我的HTML:
<div class="post">
<span class="glyphicon glyphicon-grain"> </span>
<h2> Lorem ipsum dolor sit amet, consetetur sadipscing elitr</h2>
</div>
<div class="post" id="scene">
<span class="glyphicon glyphicon-lamp" id="animation"> </span>
<h2> Lorem ipsum dolor sit amet, consetetur sadipscing elitr</h2>
</div>
有什么想法吗?
编辑:
如果我使用 github 中的指南:
// Init Controller
var scrollMagicController = new ScrollMagic.Controller();
// Create Animation for 0.5s
var tween = TweenMax.to('#animation', 0.5, {
backgroundColor: 'rgb(255, 39, 46)',
scale: 7,
rotation: 360
});
// Create the Scene and trigger when visible with ScrollMagic
var scene1 = new ScrollMagic.Scene({
triggerElement: '#scene',
offset: 150 /* offset the trigger 150px below #scene's top */
})janpaepke-ScrollMagic/scrollmagic/minified/plugins/debug.addIndicators.min.js
.setTween(tween)
.addTo(scrollMagicController);
// Add debug indicators fixed on right side
scene1.addIndicators();
我会得到这个错误:
Uncaught TypeError: (intermediate value).setTween is not a function
at HTMLDocument.<anonymous> (basic.php:70)
at c (jquery.min.js:3)
at Object.fireWith [as resolveWith] (jquery.min.js:3)
at Function.ready (jquery.min.js:3)
at HTMLDocument.H (jquery.min.js:3)
为什么!????他们的文档太糟糕了!
编辑 2:
所以我用的是下载版:
<script src="libs/janpaepke-ScrollMagic/js/lib/greensock/TweenMax.min.js"></script>
<script src="libs/janpaepke-ScrollMagic/scrollmagic/minified/plugins/animation.gsap.min.js"></script>
<!-- should be replaced with minified version when development is finished -->
<script src="libs/janpaepke-ScrollMagic/scrollmagic/minified/plugins/jquery.ScrollMagic.min.js"></script>
<!-- should be removed when development is finished -->
<script src="libs/janpaepke-ScrollMagic/scrollmagic/minified/plugins/debug.addIndicators.min.js"></script>
我收到更多错误:
jquery.ScrollMagic.min.js:2 Uncaught TypeError: Cannot read property '_util' of undefined
at jquery.ScrollMagic.min.js:2
at jquery.ScrollMagic.min.js:2
at jquery.ScrollMagic.min.js:2
(anonymous) @ jquery.ScrollMagic.min.js:2
(anonymous) @ jquery.ScrollMagic.min.js:2
(anonymous) @ jquery.ScrollMagic.min.js:2
debug.addIndicators.min.js:2 Uncaught TypeError: Cannot read property '_util' of undefined
at debug.addIndicators.min.js:2
at debug.addIndicators.min.js:2
at debug.addIndicators.min.js:2
(anonymous) @ debug.addIndicators.min.js:2
(anonymous) @ debug.addIndicators.min.js:2
(anonymous) @ debug.addIndicators.min.js:2
basic.php:65 Uncaught ReferenceError: ScrollMagic is not defined
at HTMLDocument.<anonymous> (basic.php:65)
at c (jquery.min.js:3)
at Object.fireWith [as resolveWith] (jquery.min.js:3)
at Function.ready (jquery.min.js:3)
at HTMLDocument.H (jquery.min.js:3)
文件名和文件夹结构完全是一团糟。令人困惑和不一致!
您还必须导入 gsap 插件。检查 scrollmagic 文件夹。 animation.gsap.min.js
尝试使用
new $.ScrollMagic.Scene
而不是
new ScrollMagic.Scene
应该有帮助。 如果您使用 1.3.0 版本,它可以在没有“$.”的情况下工作