This repository has been archived on 2024-12-01. You can view files and clone it, but cannot push or open issues or pull requests.
Uecko_Web/js/fullscreenSlider/jquery.slitslider.js

22 lines
7.7 KiB
JavaScript
Raw Normal View History

/**
* jquery.slitslider.js v1.1.0
* http://www.codrops.com
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2012, Codrops
* http://www.codrops.com
*/
/*
* debouncedresize: special jQuery event that happens once after a window resize
*
* latest version and complete README available on Github:
* https://github.com/louisremi/jquery-smartresize/blob/master/jquery.debouncedresize.js
*
* Copyright 2011 @louis_remi
* Licensed under the MIT license.
*/
(function(e,t,n){var r=e.event,i,s;i=r.special.debouncedresize={setup:function(){e(this).on("resize",i.handler)},teardown:function(){e(this).off("resize",i.handler)},handler:function(e,t){var n=this,o=arguments,u=function(){e.type="debouncedresize",r.dispatch.apply(n,o)};s&&clearTimeout(s),t?u():s=setTimeout(u,i.threshold)},threshold:20};var o=e(t),u=e(document),a=t.Modernizr;e.Slitslider=function(t,n){this.$elWrapper=e(n),this._init(t)},e.Slitslider.defaults={speed:800,optOpacity:!1,translateFactor:230,maxAngle:25,maxScale:2,autoplay:!1,keyboard:!0,interval:4e3,onBeforeChange:function(e,t){return!1},onAfterChange:function(e,t){return!1}},e.Slitslider.prototype={_init:function(t){this.options=e.extend(!0,{},e.Slitslider.defaults,t),this.transEndEventNames={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"MSTransitionEnd",transition:"transitionend"},this.transEndEventName=this.transEndEventNames[a.prefixed("transition")],this.support=a.csstransitions&&a.csstransforms3d,this.$el=this.$elWrapper.children(".sl-slider"),this.$slides=this.$el.children(".sl-slide").hide(),this.slidesCount=this.$slides.length,this.current=0,this.isAnimating=!1,this._getSize(),this._layout(),this._loadEvents(),this.options.autoplay&&this._startSlideshow()},_getSize:function(){this.size={width:this.$elWrapper.outerWidth(!0),height:this.$elWrapper.outerHeight(!0)}},_layout:function(){this.$slideWrapper=e('<div class="sl-slides-wrapper" />'),this.$slides.wrapAll(this.$slideWrapper).each(function(t){var n=e(this),r=n.data("orientation");n.addClass("sl-slide-"+r).children().wrapAll('<div class="sl-content-wrapper" />').wrapAll('<div class="sl-content" />')}),this._setSize(),this.$slides.eq(this.current).show()},_navigate:function(t,r){if(this.isAnimating||this.slidesCount<2)return!1;this.isAnimating=!0;var i=this,s=this.$slides.eq(this.current);r!==n?this.current=r:t==="next"?this.current=this.current<this.slidesCount-1?++this.current:0:t==="prev"&&(this.current=this.current>0?--this.current:this.slidesCount-1),this.options.onBeforeChange(s,this.current);var o=this.$slides.eq(this.current),u=t==="next"?s:o,a=u.data(),f={};f.orientation=a.orientation||"horizontal",f.slice1angle=a.slice1Rotation||0,f.slice1scale=a.slice1Scale||1,f.slice2angle=a.slice2Rotation||0,f.slice2scale=a.slice2Scale||1,this._validateValues(f);var l=f.orientation==="horizontal"?{marginTop:-this.size.height/2}:{marginLeft:-this.size.width/2},c={transform:"translate(0%,0%) rotate(0deg) scale(1)",opacity:1},h=f.orientation==="horizontal"?{transform:"translateY(-"+this.options.translateFactor+"%) rotate("+f.slice1angle+"deg) scale("+f.slice1scale+")"}:{transform:"translateX(-"+this.options.translateFactor+"%) rotate("+f.slice1angle+"deg) scale("+f.slice1scale+")"},p=f.orientation==="horizontal"?{transform:"translateY("+this.options.translateFactor+"%) rotate("+f.slice2angle+"deg) scale("+f.slice2scale+")"}:{transform:"translateX("+this.options.translateFactor+"%) rotate("+f.slice2angle+"deg) scale("+f.slice2scale+")"};this.options.optOpacity&&(h.opacity=0,p.opacity=0),s.removeClass("sl-trans-elems");var d={transition:"all "+this.options.speed+"ms ease-in-out"};u.css("z-index",this.slidesCount).find("div.sl-content-wrapper").wrap(e('<div class="sl-content-slice" />').css(d)).parent().cond(t==="prev",function(){var e=this;this.css(h),setTimeout(function(){e.css(c)},50)},function(){var e=this;setTimeout(function(){e.css(h)},50)}).clone().appendTo(u).cond(t==="prev",function(){var e=this;this.css(p),setTimeout(function(){s.addClass("sl-trans-back-elems"),i.support?e.css(c).on(i.transEndEventName,function(){i._onEndNavigate(e,s,t)}):i._onEndNavigate(e,s,t)},50)},function(){var e=this;setTimeout(function(){o.addClass("sl-trans-elems"),i.support?e.css(p).on(i.transEndEventName,function(){i._onEndNavigate(e,s,t)}):i._onEndNavigate(e,s,t)},50)}).find("div.sl-content-wrapper").css(l),o.show()},_validateValues:function(e){if(e.slice1angle>this.options.maxAngle||e.slice1angle<-this.options.maxAngle)e.slice1angle=this.options.maxAngle