[英]run Jquery function when window size greater than 800
i do some greensock and scrollmagic animation. 我做一些绿袜子和scrollmagic动画。 I put this animation inside a function called scrollMgc. 我将此动画放入了名为scrollMgc的函数中。 this animation will run when the window width greater than 800px and will stop when the window less than 800px on resize. 当窗口宽度大于800px时,该动画将运行;当窗口尺寸小于800px时,该动画将停止。 This the code i wrote so far 这是我到目前为止编写的代码
function scrollMgc(){
// Prepare the stage
TweenMax.set($('.animation-awards'), {y: 70});
// Make scrollmagic controller
var controller = new ScrollMagic.Controller();
// Create awards scene
var awardScene = new ScrollMagic.Scene({
triggerElement: '.awards',
triggerHook: 0.8,
duration: '270%'
})
.setTween(TweenMax.to('.animation-awards', 1, {y: '-=300'}))
.addIndicators({})
.addTo(controller);
}
$(window).resize(function(){
if($(this).width > 800){
scrollMgc();
}
else{
scrollMgc = undefined;
}
})
Can anybody help me out of this issue? 有人可以帮我解决这个问题吗?
Change your code as below as width is a function: 如下更改您的代码,因为width是一个函数:
if($(this).width() > 800){
scrollMgc();
}
else{
scrollMgc = undefined;
}
$(this).width是一个函数。
$(this).width()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.