You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
6.0 KiB
1 lines
6.0 KiB
Skroll=function(t){var n=$.extend({mobile:!1},t),a=this;this.elements=[],this.inViewport=function(t,n){var a=$(window),s=t.data("skrollData").offset.top,i=s+t.outerHeight(),o=a.scrollTop()+a.height()*n.triggerTop,e=a.scrollTop()+a.height()*n.triggerBottom;return i>o&&s<e},this.getScrollStatus=function(t,n){return this.inViewport(t,n)?(t.data("skrollData").inView=!0,{action:"enter",data:t.data("skrollData")}):t.data("skrollData").inView?(t.data("skrollData").inView=!1,{action:"leave",data:t.data("skrollData")}):{action:"idle",data:t.data("skrollData")}},this.add=function(t,n){var s=$.extend({triggerTop:.2,triggerBottom:.8,delay:0,duration:500,animation:"zoomIn",easing:"ease",wait:0,repeat:!1,onEnter:!1,onLeave:!1},n);return a.elements.push({element:t,settings:s}),a},this.recalcPosition=function(){$.each(a.elements,function(t,n){$(n.element).each(function(t,n){var a=$(n);if(!a.data("skrollData").shown){var s=a.css("transform");a.css("transform","none"),a.data("skrollData").offset=a.offset(),a.css("transform",s)}})})},this.throttle=function(t,n,a){var s,i;return n||(n=250),function(){var o=a||this,e=+new Date,r=arguments;s&&e<s+n?(clearTimeout(i),i=setTimeout(function(){s=e,t.apply(o,r)},n)):(s=e,t.apply(o,r))}},this.addAnimation=function(t,n){return a.animations[t]=n,a},this.init=function(){return!n.mobile&&$(window).width()<600?a:($.each(a.elements,function(t,n){$(n.element).each(function(t,s){$(s).data("skrollData",{inView:!1,shown:!1,offset:$(s).offset()}),"string"==typeof n.settings.animation&&"none"!=n.settings.animation?(a.animations[n.settings.animation]||(console.warn("The requested animation '%s' was not found switching to default zoomIn",n.settings.animation),console.trace(),n.settings.animation="zoomIn"),a.animations[n.settings.animation].start(s)):"object"==typeof n.settings.animation&&void 0!=n.settings.animation.start&&n.settings.animation.start(s)})}),$(window).on("resize scroll",this.throttle(function(){$.each(a.elements,function(t,n){var s=n.settings.wait;$(n.element).each(function(t,i){var o=$(i),e=a.getScrollStatus(o,n.settings);"idle"!=e.action&&("enter"!=e.action||e.data.shown?"leave"==e.action&&e.data.shown&&n.settings.repeat&&("string"==typeof n.settings.animation&&"none"!=n.settings.animation?a.animations[n.settings.animation]&&o.css("transition","all "+n.settings.duration+"ms "+n.settings.easing).delay(s).queue(function(t){a.animations[n.settings.animation].start(i),o.data("skrollData").shown=!1,t()}):"object"==typeof n.settings.animation&&void 0!=n.settings.animation.end&&o.css("transition","all "+n.settings.duration+"ms "+n.settings.easing).delay(s).queue(function(t){n.settings.animation.start(i),o.data("skrollData").shown=!1,t()}),s+=n.settings.delay):("string"==typeof n.settings.animation&&"none"!=n.settings.animation?o.css("transition","all "+n.settings.duration+"ms "+n.settings.easing).delay(s).queue(function(t){a.animations[n.settings.animation].end(i),o.data("skrollData").shown=!0,t()}):"object"==typeof n.settings.animation&&void 0!=n.settings.animation.end&&o.css("transition","all "+n.settings.duration+"ms "+n.settings.easing).delay(s).queue(function(t){n.settings.animation.end(i),o.data("skrollData").shown=!0,t()}),s+=n.settings.delay),"enter"==e.action?n.settings.onEnter&&n.settings.onEnter(t,i):"leave"==e.action&&n.settings.onLeave&&n.settings.onLeave(t,i))})})},150)),$(window).scroll(),$(window).resize(this.recalcPosition()),a)},this.animations={zoomIn:{start:function(t){$(t).css({transform:"scale(.1,.1)",opacity:0})},end:function(t){$(t).css({transform:"scale(1,1)",opacity:1})}},fadeInLeft:{start:function(t){$(t).css({transform:"translate(-50%,0)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0)",opacity:1})}},fadeInRight:{start:function(t){$(t).css({transform:"translate(50%,0)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0)",opacity:1})}},fadeInLeftBig:{start:function(t){$(t).css({transform:"translate(-100%,0)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0)",opacity:1})}},fadeInRightBig:{start:function(t){$(t).css({transform:"translate(100%,0)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0)",opacity:1})}},fadeInUp:{start:function(t){$(t).css({transform:"translate(0,50%)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0)",opacity:1})}},fadeInDown:{start:function(t){$(t).css({transform:"translate(0,-50%)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0)",opacity:1})}},slideInLeft:{start:function(t){$(t).css({transform:"translate(-50%,0) scale(.8,.8)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0) scale(1,1)",opacity:1})}},slideInLeftBig:{start:function(t){$(t).css({transform:"translate(-100%,0) scale(.8,.8)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0) scale(1,1)",opacity:1})}},slideInRight:{start:function(t){$(t).css({transform:"translate(50%,0) scale(.8,.8)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0) scale(1,1)",opacity:1})}},slideInRightBig:{start:function(t){$(t).css({transform:"translate(-100%,0) scale(.8,.8)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0) scale(1,1)",opacity:1})}},flipInX:{start:function(t){$(t).css({transform:"rotateX(90deg)",opacity:0})},end:function(t){$(t).css({transform:"rotateX(0deg)",opacity:1})}},flipInY:{start:function(t){$(t).css({transform:"rotateY(90deg)",opacity:0})},end:function(t){$(t).css({transform:"rotateY(0deg)",opacity:1})}},rotateRightIn:{start:function(t){$(t).css({transform:"rotate(45deg)",transformOrigin:"0 100%",opacity:0})},end:function(t){$(t).css({transform:"rotate(0deg)",opacity:1})}},rotateLeftIn:{start:function(t){$(t).css({transform:"rotate(-45deg)",transformOrigin:"0 100%",opacity:0})},end:function(t){$(t).css({transform:"rotate(0deg)",opacity:1})}},growInLeft:{start:function(t){$(t).css({transform:"translate(-100%,0) scale(.1,.1)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0) scale(1,1)",opacity:1})}},growInRight:{start:function(t){$(t).css({transform:"translate(100%,0) scale(.1,.1)",opacity:0})},end:function(t){$(t).css({transform:"translate(0,0) scale(1,1)",opacity:1})}}}};
|