PATH:
home
/
letacommog
/
letaweb
/
scripts
/
libraries
/
master-slider
// Converts JS prefix to CSS prefix var trans = { 'Moz' : '-moz-', 'Webkit' : '-webkit-', 'Khtml' : '-khtml-' , 'O' : '-o-', 'ms' : '-ms-', 'Icab' : '-icab-' }; window._mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) window._touch = 'ontouchstart' in document; $(document).ready(function(){ window._jcsspfx = getVendorPrefix(); // JS CSS VendorPrefix window._csspfx = trans[window._jcsspfx]; // CSS VendorPrefix window._cssanim = supportsTransitions(); window._css3d = supports3DTransforms(); window._css2d = supportsTransforms(); }); // Thanks to LEA VEROU // http://lea.verou.me/2009/02/find-the-vendor-prefix-of-the-current-browser/ function getVendorPrefix() { if('result' in arguments.callee) return arguments.callee.result; var regex = /^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/; var someScript = document.getElementsByTagName('script')[0]; for(var prop in someScript.style){ if(regex.test(prop)){ return arguments.callee.result = prop.match(regex)[0]; } } if('WebkitOpacity' in someScript.style) return arguments.callee.result = 'Webkit'; if('KhtmlOpacity' in someScript.style) return arguments.callee.result = 'Khtml'; return arguments.callee.result = ''; } // Thanks to Steven Benner. // http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/ window.parseQueryString = function(url){ var queryString = {}; url.replace( new RegExp("([^?=&]+)(=([^&]*))?", "g"), function($0, $1, $2, $3) { queryString[$1] = $3; } ); return queryString; }; function checkStyleValue(prop){ var b = document.body || document.documentElement; var s = b.style; var p = prop; if(typeof s[p] == 'string') {return true; } // Tests for vendor specific prop v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms'], p = p.charAt(0).toUpperCase() + p.substr(1); for(var i=0; i<v.length; i++) { if(typeof s[v[i] + p] == 'string') { return true; } } return false; } function supportsTransitions() { return checkStyleValue('transition'); } function supportsTransforms(){ return checkStyleValue('transform'); } function supports3DTransforms(){ if(!supportsTransforms()) return false; var el = document.createElement('i'), has3d, transforms = { 'WebkitTransform':'-webkit-transform', 'OTransform':'-o-transform', 'MSTransform':'-ms-transform', 'msTransform':'-ms-transform', 'MozTransform':'-moz-transform', 'Transform':'transform', 'transform':'transform' }; el.style.display = 'block'; // Add it to the body to get the computed style document.body.insertBefore(el, null); for(var t in transforms){ if( el.style[t] !== undefined ){ el.style[t] = 'translate3d(1px,1px,1px)'; has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]); } } document.body.removeChild(el); return (has3d != null && has3d.length > 0 && has3d !== "none"); } /** * Provides requestAnimationFrame in a cross browser way. * @author paulirish / http://paulirish.com/ */ var fps60 = 50/3; if ( !window.requestAnimationFrame ) { window.requestAnimationFrame = ( function() { return window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) { window.setTimeout( callback, fps60 ); }; } )(); } if (!window.getComputedStyle) { window.getComputedStyle = function(el, pseudo) { this.el = el; this.getPropertyValue = function(prop) { var re = /(\-([a-z]){1})/g; if (prop == 'float') prop = 'styleFloat'; if (re.test(prop)) { prop = prop.replace(re, function () { return arguments[2].toUpperCase(); }); } return el.currentStyle[prop] ? el.currentStyle[prop] : null; }; return el.currentStyle; }; } ;(function(){ // Thanks to matthewlein // https://github.com/matthewlein/Ceaser window.EaseDic = { 'linear' : 'linear', 'ease' : 'ease', 'easeIn' : 'ease-in', 'easeOut' : 'ease-out', 'easeInOut' : 'ease-in-out', 'easeInCubic' : 'cubic-bezier(.55,.055,.675,.19)', 'easeOutCubic' : 'cubic-bezier(.215,.61,.355,1)', 'easeInOutCubic' : 'cubic-bezier(.645,.045,.355,1)', 'easeInCirc' : 'cubic-bezier(.6,.04,.98,.335)', 'easeOutCirc' : 'cubic-bezier(.075,.82,.165,1)', 'easeInOutCirc' : 'cubic-bezier(.785,.135,.15,.86)', 'easeInExpo' : 'cubic-bezier(.95,.05,.795,.035)', 'easeOutExpo' : 'cubic-bezier(.19,1,.22,1)', 'easeInOutExpo' : 'cubic-bezier(1,0,0,1)', 'easeInQuad' : 'cubic-bezier(.55,.085,.68,.53)', 'easeOutQuad' : 'cubic-bezier(.25,.46,.45,.94)', 'easeInOutQuad' : 'cubic-bezier(.455,.03,.515,.955)', 'easeInQuart' : 'cubic-bezier(.895,.03,.685,.22)', 'easeOutQuart' : 'cubic-bezier(.165,.84,.44,1)', 'easeInOutQuart' : 'cubic-bezier(.77,0,.175,1)', 'easeInQuint' : 'cubic-bezier(.755,.05,.855,.06)', 'easeOutQuint' : 'cubic-bezier(.23,1,.32,1)', 'easeInOutQuint' : 'cubic-bezier(.86,0,.07,1)', 'easeInSine' : 'cubic-bezier(.47,0,.745,.715)', 'easeOutSine' : 'cubic-bezier(.39,.575,.565,1)', 'easeInOutSine' : 'cubic-bezier(.445,.05,.55,.95)', 'easeInBack' : 'cubic-bezier(.6,-.28,.735,.045)', 'easeOutBack' : 'cubic-bezier(.175, .885,.32,1.275)', 'easeInOutBack' : 'cubic-bezier(.68,-.55,.265,1.55)' }; })(); /** * Touch List Control * version 1.1.2 * * Copyright (C) 2014, Averta Ltd. All rights reserved. */ ;(function(){ "use strict"; var _options = { bouncing : true, snapping : false, snapsize : null, friction : 0.05, outFriction : 0.05, outAcceleration : 0.09, minValidDist : 0.3, snappingMinSpeed : 2, paging : false, endless : false, maxSpeed : 160 }; var Controller = function(min , max , options){ if(max === null || min === null) { throw new Error('Max and Min values are required.'); } this.options = options || {}; for(var key in _options){ if(!(key in this.options)) this.options[key] = _options[key]; } this._max_value = max; this._min_value = min; this.value = min; this.end_loc = min; this.current_snap = this.getSnapNum(min); this.__extrStep = 0; this.__extraMove = 0; this.__animID = -1; }; var p = Controller.prototype; /* --------------------------------------------------- PUBLIC METHODS ---------------------------------------------------- */ p.changeTo = function(value , animate , speed , snap_num , dispatch) { this.stopped = false; this._internalStop(); value = this._checkLimits(value); speed = Math.abs(speed || 0); if(this.options.snapping){ snap_num = snap_num || this.getSnapNum(value); if( dispatch !== false )this._callsnapChange(snap_num); this.current_snap = snap_num; } if(animate){ this.animating = true; var self = this, active_id = ++self.__animID, amplitude = value - self.value, timeStep = 0, targetPosition = value, animFrict = 1 - self.options.friction, timeconst = animFrict + (speed - 20) * animFrict * 1.3 / self.options.maxSpeed; var tick = function(){ if(active_id !== self.__animID) return; var dis = value - self.value; if( Math.abs(dis) > self.options.minValidDist && self.animating ){ window.requestAnimationFrame(tick); } else { if( self.animating ){ self.value = value; self._callrenderer(); } self.animating = false; if( active_id !== self.__animID ){ self.__animID = -1; } self._callonComplete('anim'); return; } //self.value += dis * timeconst self.value = targetPosition - amplitude * Math.exp(-++timeStep * timeconst); self._callrenderer(); }; tick(); return; } this.value = value; this._callrenderer(); }; p.drag = function(move){ if(this.start_drag){ this.drag_start_loc = this.value; this.start_drag = false; } this.animating = false; this._deceleration = false; this.value -= move; if ( !this.options.endless && (this.value > this._max_value || this.value < 0)) { if (this.options.bouncing) { this.__isout = true; this.value += move * 0.6; } else if (this.value > this._max_value) { this.value = this._max_value; } else { this.value = 0; } }else if(!this.options.endless && this.options.bouncing){ this.__isout = false; } this._callrenderer(); }; p.push = function(speed){ this.stopped = false; if(this.options.snapping && Math.abs(speed) <= this.options.snappingMinSpeed){ this.cancel(); return; } this.__speed = speed; this.__startSpeed = speed; this.end_loc = this._calculateEnd(); if(this.options.snapping){ var snap_loc = this.getSnapNum(this.value), end_snap = this.getSnapNum(this.end_loc); if(this.options.paging){ snap_loc = this.getSnapNum(this.drag_start_loc); this.__isout = false; if(speed > 0){ this.gotoSnap(snap_loc + 1 , true , speed); }else{ this.gotoSnap(snap_loc - 1 , true , speed); } return; }else if(snap_loc === end_snap){ this.cancel(); return; } this._callsnapChange(end_snap); this.current_snap = end_snap; } this.animating = false; this.__needsSnap = this.options.endless || (this.end_loc > this._min_value && this.end_loc < this._max_value) ; if(this.options.snapping && this.__needsSnap) this.__extraMove = this._calculateExtraMove(this.end_loc); this._startDecelaration(); }; p.bounce = function(speed){ if(this.animating) return; this.stopped = false; this.animating = false; this.__speed = speed; this.__startSpeed = speed; this.end_loc = this._calculateEnd(); //if(this.options.paging){} this._startDecelaration(); }; p.stop = function(){ this.stopped = true; this._internalStop(); }; p.cancel = function(){ this.start_drag = true; // reset flag for next drag if(this.__isout){ this.__speed = 0.0004; this._startDecelaration(); }else if(this.options.snapping){ this.gotoSnap(this.getSnapNum(this.value) , true); } }; p.renderCallback = function(listener , ref){ this.__renderHook = {fun:listener , ref:ref}; }; p.snappingCallback = function(listener , ref){ this.__snapHook = {fun:listener , ref:ref}; }; p.snapCompleteCallback = function(listener , ref){ this.__compHook = {fun:listener , ref:ref}; }; p.getSnapNum = function(value){ return Math.floor(( value + this.options.snapsize / 2 ) / this.options.snapsize); }; p.nextSnap = function(){ this._internalStop(); var curr_snap = this.getSnapNum(this.value); if(!this.options.endless && (curr_snap + 1) * this.options.snapsize > this._max_value){ this.__speed = 8; this.__needsSnap = false; this._startDecelaration(); }else{ this.gotoSnap(curr_snap + 1 , true); } }; p.prevSnap = function(){ this._internalStop(); var curr_snap = this.getSnapNum(this.value); if(!this.options.endless && (curr_snap - 1) * this.options.snapsize < this._min_value){ this.__speed = -8; this.__needsSnap = false; this._startDecelaration(); }else{ this.gotoSnap(curr_snap - 1 , true); } }; p.gotoSnap = function(snap_num , animate , speed){ this.changeTo(snap_num * this.options.snapsize , animate , speed , snap_num); }; p.destroy = function(){ this._internalStop(); this.__renderHook = null; this.__snapHook = null; this.__compHook = null; }; /* --------------------------------------------------- PRIVATE METHODS ---------------------------------------------------- */ p._internalStop = function(){ this.start_drag = true; // reset flag for next drag this.animating = false; this._deceleration = false; this.__extrStep = 0; }; p._calculateExtraMove = function(value){ var m = value % this.options.snapsize; return m < this.options.snapsize / 2 ? -m : this.options.snapsize - m; }; p._calculateEnd = function(step){ var temp_speed = this.__speed; var temp_value = this.value; var i = 0; while(Math.abs(temp_speed) > this.options.minValidDist){ temp_value += temp_speed; temp_speed *= this.options.friction; i++; } if(step) return i; return temp_value; }; p._checkLimits = function(value){ if(this.options.endless) return value; if(value < this._min_value) return this._min_value; if(value > this._max_value) return this._max_value; return value; }; p._callrenderer = function(){ if(this.__renderHook) this.__renderHook.fun.call(this.__renderHook.ref , this , this.value); }; p._callsnapChange = function(targetSnap){ if(!this.__snapHook || targetSnap === this.current_snap) return; this.__snapHook.fun.call(this.__snapHook.ref , this , targetSnap , targetSnap - this.current_snap); }; p._callonComplete = function(type){ if(this.__compHook && !this.stopped){ this.__compHook.fun.call(this.__compHook.ref , this , this.current_snap , type); } }; p._computeDeceleration = function(){ if(this.options.snapping && this.__needsSnap){ var xtr_move = (this.__startSpeed - this.__speed) / this.__startSpeed * this.__extraMove; this.value += this.__speed + xtr_move - this.__extrStep; this.__extrStep = xtr_move; }else{ this.value += this.__speed; } this.__speed *= this.options.friction; //* 10; if(!this.options.endless && !this.options.bouncing){ if(this.value <= this._min_value){ this.value = this._min_value; this.__speed = 0; }else if(this.value >= this._max_value){ this.value = this._max_value; this.__speed = 0; } } this._callrenderer(); if(!this.options.endless && this.options.bouncing){ var out_value = 0; if(this.value < this._min_value){ out_value = this._min_value - this.value; }else if(this.value > this._max_value){ out_value = this._max_value - this.value; } this.__isout = Math.abs(out_value) >= this.options.minValidDist; if(this.__isout){ if(this.__speed * out_value <= 0){ this.__speed += out_value * this.options.outFriction; }else { this.__speed = out_value * this.options.outAcceleration; } } } }; p._startDecelaration = function(){ if(this._deceleration) return; this._deceleration = true; var self = this; var tick = function (){ if(!self._deceleration) return; self._computeDeceleration(); if(Math.abs(self.__speed) > self.options.minValidDist || self.__isout){ window.requestAnimationFrame(tick); }else{ self._deceleration = false; self.__isout = false; if(self.__needsSnap && self.options.snapping && !self.options.paging){ self.value = self._checkLimits(self.end_loc + self.__extraMove); }else{ self.value = Math.round(self.value); } self._callrenderer(); self._callonComplete('decel'); } }; tick(); }; window.Controller = Controller; })(); (function($){ $.fn.preloadImg = function(src , _event){ this.each(function(){ var $this = $(this); var self = this; var img = new Image(); img.onload = function(event){ if(event == null) event = {}; // IE8 $this.attr('src' , src); event.width = img.width; event.height = img.height; $this.data('width', img.width); $this.data('height', img.height); setTimeout(function(){_event.call(self , event);},50); img = null; }; img.src = src; }); return this; }; }); var STSliderTimer = function(delay) { this.initTime = (new Date).getTime(); this.startTime,this.isStop = !1; this.start = function() { this.isStop && (this.startTime = (new Date).getTime(),STSliderTimer.addClock(this),this.isStop=!0); } this.stop = function() { !this.isStop && (STSliderTimer.removeClock(this)); } } var __clockTick = function() { } STSliderTimer.clocks = []; STSliderTimer.addClock = function(clock) { STSliderTimer.clocks.push(clock); } STSliderTimer.removeClock = function(clock) { STSliderTimer.clocks.push(clock); } var STSliderEvent = function(slider) { this.slider = slider; // Attach an event handler to the slider this.on= function( type, callback ) { return this.slider.element.on( type, callback ); }; // Detach an event handler this.off= function( type ) { return this.slider.element.off( type ); }; // Trigger an event on the slider this.trigger= function( data ) { return this.slider.element.triggerHandler( data ); }; } STSliderEvent.CHANGE_START = 'on_change_start'; STSliderEvent.CHANGE_END = 'on_change_end'; STSliderEvent.SWIPE_START = 'on_swipe_end'; STSliderEvent.SWIPE_END = 'on_swipe_end'; STSliderEvent.RESIZE = 'on_resize'; STSliderEvent.SLIDE_READY ='on_slide_ready'; var STSlider = function(element,options) { this.element = $(element); this.options = $.extend({}, STSlider.options,options); this.initSlide = function() { } this.setupSlide = function() { this.init(); } this.initSize= function() { if(!this.options.width) { this.options.autowidth = true; this.options.width = this.element.width(); } if(!this.options.height) { this.options.autoheight = true; this.options.height = this.options.width * this.options.h_radio; } this.hRatio = this.options.width/this.element.width(); this.vRatio = this.options.height/this.element.height(); this.aspect_ratio = this.options.width/this.options.height; //this.container_inner.css('max-width', this.options.width+'px'); this.options.owidth = this.options.width; this.options.oheight =this.options.height; this.options.oldww = $(window).width(); var that = this; $(window).on('resize', function() { that.onResize(); }); } this.createArrows = function() { var left_arrow = $('<div class="sts-left-arrow"/>'); var right_arrow = $('<div class="sts-right-arrow"/>'); this.container_inner.append(left_arrow).append(right_arrow); } this.onResize = function() { this.resize_ratio = $(window).width()/this.options.oldww; this.event.trigger(STSliderEvent.RESIZE); } this.init = function() { this.slides = []; this.element.wrapInner('<div class="st-container-src"/>'); this.element_src = this.element.children('.st-container-src');this.element_src.hide(); this.container = $('<div class="st-container"/>'); this.element.append(this.container); this.container_inner = $('<div class="st-container-inner"/>'); this.container.wrapInner(this.container_inner); this.initTimer(); this.initSize(); this.event = new STSliderEvent(this); this.slideController = new STSliderSlideController(this); this.api = this.slideController; this.createArrows(); }; this.initTimer = function() { //this.timer = new STSliderTimer(); this.timerElement = $('<div class="st-timer-rotator"/>'); this.container_inner.append(this.timerElement); this.timer = new ANIMO.Animo(this.timerElement[0], {width:'0%'}, {width:'100%'}).duration(this.options.time); this.timer.repeat(Infinity); var that = this; this.timer.onUpdate (function(value) { if(value==1) { that.slideController.pauseTimer(); that.slideController.next(false); } }); } this.initController = function() { } } STSlider.options= { h_radio:9/16, slider_class:'st-slider', touchSwipe:true, view:'basic', time:9000, autoPlay:true }; var STSliderSlideController = function(slider) { this.slides = []; this.paused = false; this.slider = slider; this.loaded = false; this.init = function() { this.bindEvent(); this.setupView(); this.loaded = true; } this.pause = function() { this.paused = true; this.pauseTimer(); } this.stop = function() { this.stopped = true; this.stopTimer(); } this.addEventListener = function(e, callback, ref) { this.slider.event.on(e, function(event, data) { callback.call(ref, event,data); }); } this.startTimer = function() { if(!this.slider.options.autoPlay) return; if(this.paused) return; if(this._timerStarted) return; this.slider.timer.start(); this._timerStarted = true; } this.pauseTimer = function() { // if(this.timerPaused) // return; this.slider.timer.pause(); this.timerPaused =true; } this.resumeTimer = function() { if(this.paused) return; if(!this.timerPaused) return; delete this.timerPaused; this.slider.timer.resume(); } this.stopTimer = function() { this.slider.timer.stop(); } this.addSlide= function(slideElement) { var slide = new STSliderSlide(slideElement,this); this.slides.push(slide); return slide; } this.setupView = function() { this.view = STSliderView.initView(this, this.slider.options.view||'basic'); this.view.init(); var that = this; $(this.slider.element_src).children().each(function(index, element) { var slide = that.addSlide(this); that.view.addSlide(slide); }); this.view.run(); }; this.next = function(instant) { this.view.nextSlide(instant); } this.bindEvent = function() { var that = this; this.slider.event.on(STSliderEvent.SLIDE_READY, function(event, data) { }); this.slider.event.on(STSliderEvent.CHANGE_START, function(event, data) { var slide = event.next_slide; slide.waitToSelect(); that.pauseTimer(); }); this.slider.event.on(STSliderEvent.CHANGE_END, function(event, data) { if(that.currentSlide) { that.currentSlide.deselect(); } that.resumeTimer(); var slide = event.slide; that.currentSlide = slide; that.currentSlide.select(); }); this.slider.event.on(STSliderEvent.RESIZE, function(event, data) { that.resize(); }); } this.resize = function() { if(!this.loaded) return; //this.width = this.slider.element[0].clientWidth || this.so.width; //this.so.fullwidth || (this.width = Math.min(this.width, this.so.width)); //this.so.fullheight ? (this.so.heightLimit = !1, this.so.autoHeight = !1, this.height = this.slider.element[0].clientHeight) : this.height = this.width / this.slider.aspect, this.so.autoHeight ? (this.currentSlide.setSize(this.width, null, hard), this.view.setSize(this.width, this.currentSlide.getHeight(), hard)) : this.view.setSize(this.width, Math.max(this.so.minHeight, this.so.heightLimit ? Math.min(this.height, this.so.height) : this.height), hard), this.slider.$controlsCont && this.so.centerControls && this.so.fullwidth && this.view.$element.css("left", Math.min(0, -(this.slider.element[0].clientWidth - this.so.width) / 2) + "px")) } this.gotoSlide = function(index) { this.view.gotoSlide(index); } this.init(); }; var STSliderView = function() { this.currentSlide=0; this.index=0; this.slideList=[]; this.slides_order = []; this.slides = []; this.viewSlides=[]; this.options={ loop:true, direction:'h', margin:0, start_slide:6, slide_distance:0, touchSwipeThreshold:50, //slidesToShow:1, }; this.position = 0; this.transitionCSS =this.options.direction =='h' ? 'translateX':'translateY'; this.defaultTransitionCSS = this.options.direction =='h' ? 'translateZ(0) translateY(0)' : 'translateZ(0) translateX(0)'; this.positionAttr = this.options.direction =='h' ? 'left':'top'; this.dimensionAttr =this.options.direction =='h' ? 'width':'height'; this.addSlide = function(slide) { slide.view = this; this.slides.push(slide); this.slideList.push(slide); slide.init(); } this.updateViewSlide = function() { this.viewSlides=[]; } this.createSlideOrder = function() { if(!this.options.loop) for(var i = 0;i < this.slides.length;i++) { this.slides_order.push(i); } else { var slideCount = this.getTotalSlides(); var half = slideCount /2; var lHalf = half%2 == 0 ? half-1:Math.floor(half); var rHalf = half%2 == 0 ? half:Math.floor(half); for(var i = 1;i <= lHalf;i++) { this.slides_order.unshift((this.index - i < 0)? slideCount - i + this.index: this.index - i); } this.slides_order.push(this.index); for(var i = 1;i <= rHalf;i++) { this.slides_order.push((this.index + i >= slideCount)? this.index + i - slideCount : this.index + i); } } } this.changeLoopStart = function() { var firstSlide = this.slides[this.slides_order[0]]; var last = this.slides_order.pop(); var lastSlide = this.slides[last]; this.slides_order.unshift(last); lastSlide.position = firstSlide.position - this[this.dimensionAttr]; lastSlide.element.css(this.positionAttr, lastSlide.position+'px'); } this.changeLoopEnd = function() { var lastSlide = this.slides[this.slides_order[this.slides_order.length-1]]; var first = this.slides_order.shift(); var firstSlide = this.slides[first]; this.slides_order.push(first); firstSlide.position = firstSlide.position + this[this.dimensionAttr]; firstSlide.element.css(this.positionAttr, firstSlide.position+'px'); } this.updateSlidesOrder = function(index) { if(this.options.loop) { var delta = index - this.slideOrderIndex; for(var i = 0;i < Math.abs(delta);i++) { if(delta < 0) { this.changeLoopStart(); } else { this.changeLoopEnd(); } } } } this.getSlideOrderIndex = function(index) { for(var i = 0;i < this.slides_order.length;i++) { if(this.slides_order[i] == index) return i; } return false; } this.nextSlide = function(instant) { var nextIndex = this.index + 1; ((this.index +1) >= this.slides.length) && (nextIndex=0); // ((this.index + 1) > this.slides.length) && (nextIndex=0); this.gotoSlide(nextIndex,instant); } this.gotoSlide = function(index,instant) { this.index = index; this.slideOrderIndex = this.getSlideOrderIndex(index); var nextSlide = this.slides[index]; var offset = nextSlide.position; this.slider.event.trigger({type:STSliderEvent.CHANGE_START, next_slide:nextSlide}); this.slideChanged=true; this.controller.changeTo(offset,!instant, null, null,false); if(instant) this.slider.event.trigger({type:STSliderEvent.CHANGE_END, slide:nextSlide}); } this.positionSlides = function(move) { var offset = 0; var position = this.position || 0; for(var i = 0;i < this.slides_order.length;i++) { this.slides[ this.slides_order[i] ].element.css(this.positionAttr,offset+'px'); this.slides[ this.slides_order[i] ].position = offset; offset+= this.width; } if(move) this.controller.changeTo(this.slides[this.index].position,false,0,null, false); } this.__snapUpdate = function(controller , snap , change) { if(change == undefined || isNaN(change)) return; this.updateSlidesOrder(this.slideOrderIndex + change); var slideOrderIndex = this.getSlideOrderIndex(this.index); var target = slideOrderIndex + change; if(target <0 || target >= this.slides_order.length) return; this.index = this.slides_order[target]; this.slideOrderIndex = slideOrderIndex; this.slideChanged=true; var nextSlide = this.slides[this.index]; this.slider.event.trigger({type:STSliderEvent.CHANGE_START, next_slide:nextSlide}); } this.__snapCompelete = function() { if ( !this.slideChanged ) { return; } this.slideChanged = false; this.positionSlides(true); this.start_buffer = 0; this.slider.event.trigger({type:STSliderEvent.CHANGE_END, slide:this.slides[this.index]}); } this.run = function() { for(var i = 0;i < this.slides.length;i++) { this.slides[i].create(); } this.index = this.options.start_slide-1; this.createSlideOrder(); this.initSize(); this.position=0; this.positionSlides(); this.gotoSlide(this.index,true); } this.initSlidesSize = function() { for(var i = 0;i < this.slides.length;i++) { this.slides[i].initSize(); } } this._updatePosition = function(tcontrol, position) { this.position = position; if(this.css3) { this.slideContainer[0].style[window._jcsspfx + 'Transform'] = this.transitionCSS + '('+ (-position)+'px) '; return; } this.slideContainer[0].style[this.positionAttr] = -position + 'px'; }; this.initSize = function() { this.resize(); } this.resize = function() { this.resize_ratio = this.slideController.slider.resize_ratio; this.width = this.slideController.slider.options.width; this.width = Math.min(this.width, this.slideController.slider.element.width()); this.height = this.slideController.slider.options.height; this.resize_factor = this.width/this.slideController.slider.options.width; if(this.width!=this.slideController.slider.options.width) this.height = this.slideController.slider.options.height*(this.width/this.slideController.slider.options.width); this.element.width(this.width).height(this.height); this.view_size = this.width*(this.slides.length-1); this.controller._max_value = this.view_size; this.controller.options.snapsize = this[this.dimensionAttr]; this.slide_size = this.positionAttr == 'left'? this.width:this.height; this.initSlidesSize(); } this.getTotalSlides = function() { return this.slides.length; } this.initTouchSwipe = function() { if(this.slideController.slider.options.touchSwipe) { var that = this; this.touchSwipeController = new STTouchSwipe(this.element, { direction:this.options.direction, onTouchStart: function() { this.touchStartPosition = that.position; }, onTouchMove: function(distance,move) { if((move==undefined || isNaN(move))) { return; } that.controller.drag(move); }, onTouchEnd: function(distance,duration) { if((distance==undefined || isNaN(distance)) || duration==0) { that.controller.cancel(); return; } var speed = distance / duration * 50/3; if(Math.abs(speed) > 0.1){ that.controller.push(-speed); //if(speed > that.controller.options.snappingMinSpeed) //this.dispatchEvent(new MSViewEvents(MSViewEvents.SWIPE_END, status)); }else { that.controller.cancel(); //this.dispatchEvent(new MSViewEvents(MSViewEvents.SWIPE_CANCEL, status)); } //that.controller.cancel(); } }); this.touchSwipeController.oldSlidesPosition = this.position; this.touchSwipeController.initTouchSwipe(); } } this._init = function() { this.css3 = window._cssanim; this.element = $('<div class="st-view"/>'); this.element.addClass(this.viewClass); this.slideContainer = $('<div class="st-slide-container"/>'); this.element.append(this.slideContainer); // this.element.css('overflow','hidden'); this.slideController.slider.container_inner.append(this.element); this.controller = new Controller(0,0,{ snapping:true, snapSize:100, paging:true, // snappingMinSpeed: this.options.minSlideSpeed, // friction: (100 - .5 * this.options.speed) / 100, }); this.controller.renderCallback(this._updatePosition , this); this.controller.snappingCallback(this.__snapUpdate , this); this.controller.snapCompleteCallback(this.__snapCompelete , this); this.initTouchSwipe(); } this.init = function() { this._init(); } }; STSliderView.createView = function(viewName,protype, parentView) { STSliderView.views = STSliderView.views||{}; if(parentView==undefined || parentView=='') parentView = 'basic'; var parent = STSliderView.views[parentView]||STSliderView; parentProtype =new parent; STSliderView.views[viewName] = function(){__super = parent}; var p =new protype; STSliderView.views[viewName].prototype = $.extend({},parentProtype,p); for(var i in parentProtype) { if(!parentProtype.hasOwnProperty(i)) continue; if(STSliderView.views[viewName].prototype.hasOwnProperty(i)) STSliderView.views[viewName].prototype['_' + i+'_'] = parentProtype[i]; } } STSliderView.initView = function(slideController,name) { var view = new STSliderView.views[name]; view.slideController = slideController; view.slider = slideController.slider; return view; } STSliderView.createView('basic', function() { this.viewClass = 'st-basic-view'; }); STSliderView.createView('wave', function() { this.viewClass = 'st-wave-view'; this.init = function() { this._init_(); this.slideContainer.css('transform-style','preserve-3d'); this.element.css('overflow','visible'); } this._updatePosition = function(tcontrol, position) { this.__updatePosition_.call(this,tcontrol, position); for(var i =0 ;i < this.slides_order.length;i++) { var slide = this.slides[this.slides_order[i]]; var distance = slide.position -position; this.updatePerpective(slide, distance); } } this.updatePerpective = function(slide, distance) { var perpective = Math.abs(distance/this[this.dimensionAttr])*100; var value = -3*perpective; slide.element.css('transform','translateZ(' +value + 'px)'); } }); STSliderView.createView('fadewave', function() { this.viewClass = 'st-fadewave-view'; this.updatePerpective = function(slide, distance) { var perpective = Math.abs(distance/this[this.dimensionAttr])*100; var value = Math.min(perpective, 100); slide.element.css("opacity", 1 - value / 300); slide.element[0].style[window._jcsspfx + "Transform"] = "scale(" + (1 - value / 800) + ") rotateY(0.01deg) " } },'wave'); STSliderView.createView('fade', function() { this.viewClass = 'st-fade-view'; this.updatePerpective = function(slide, distance) { var value = Math.abs(.6 * distance / this[this.dimensionAttr]); value = 1 - Math.min(value, .6), slide.element.css("opacity", value) } },'wave'); STSliderView.createView('flow', function() { this.viewClass = 'st-flow-view'; this.updatePerpective = function(slide, distance) { var value = Math.abs(100 * distance / this[this.dimensionAttr]); rvalue = Math.min(.3 * value, 30) * (0 > distance ? -1 : 1); zvalue = 1.2 * value; slide.element[0].style[window._jcsspfx + "Transform"] = "translateZ(" + 5 * -zvalue + "px) rotateY(" + (this.positionAttr=='top'? rvalue:-rvalue) + "deg) " } },'wave'); STSliderView.createView('mask', function() { this.viewClass = 'st-mask-view'; this.positionSlides = function(move) { var offset = 0; var position = this.position || 0; for(var i = 0;i < this.slides_order.length;i++) { this.slides[ this.slides_order[i] ].mask.css(this.positionAttr,offset+'px'); this.slides[ this.slides_order[i] ].position = offset; offset+= this.width; } var rposition = this.slides[this.index].position; for(var i = 0;i < this.slides_order.length;i++) { var position = this.slides[ this.slides_order[i] ].position; if(this.css3) this.slides[ this.slides_order[i] ].element[0].style[window._jcsspfx + 'Transform'] = this.transitionCSS + '('+ (rposition-position)+'px) '; else this.slides[ this.slides_order[i] ].element[0].style[this.positionAttr] = (rposition-position) + 'px'; } if(move) this.controller.changeTo(this.slides[this.index].position,false,0,null, false); } this.changeLoopStart = function() { var firstSlide = this.slides[this.slides_order[0]]; var last = this.slides_order.pop(); var lastSlide = this.slides[last]; this.slides_order.unshift(last); lastSlide.position = firstSlide.position - this[this.dimensionAttr]; var rposition = this.slides[this.index].position; lastSlide.mask.css('left', lastSlide.position+'px'); if(this.css3) lastSlide.element[0].style[window._jcsspfx + 'Transform'] = this.transitionCSS + '('+ (rposition-lastSlide.position)+'px) '; else lastSlide.element[0].style[this.positionAttr] = (rposition-lastSlide.position) + 'px'; } this.changeLoopEnd = function() { var lastSlide = this.slides[this.slides_order[this.slides_order.length-1]]; var first = this.slides_order.shift(); var firstSlide = this.slides[first]; this.slides_order.push(first); firstSlide.position = firstSlide.position + this[this.dimensionAttr]; firstSlide.mask.css('left', firstSlide.position+'px'); var rposition = this.slides[this.index].position; if(this.css3) firstSlide.element[0].style[window._jcsspfx + 'Transform'] = this.transitionCSS + '('+ (rposition-firstSlide.position)+'px) '; else firstSlide.element[0].style[this.positionAttr] = (rposition-firstSlide.position) + 'px'; } this.addSlide = function(slide) { this._addSlide_(slide); var mask_element = $('<div class="st-mask-slide"/>'); slide.element.wrap(mask_element); slide.mask = slide.element.parent(); slide.element.css('position','relative'); } this._updatePosition = function(tcontrol, position) { this.__updatePosition_(tcontrol, position); for(var i = 0;i < this.slides_order.length;i++) { var p = this.slides[ this.slides_order[i] ].position; if(this.css3) this.slides[ this.slides_order[i] ].element[0].style[window._jcsspfx + 'Transform'] = this.transitionCSS + '('+ -(p-position)+'px) '; else this.slides[ this.slides_order[i] ].element[0].style[this.positionAttr] = -(p-position) + 'px'; } }; },'base'); STSliderView.createView('fademask', function() { this.viewClass = 'st-fademask-view'; this.init = function() { this._init_(); this.slideContainer.css('transform-style','preserve-3d'); this.element.css('overflow','visible'); } this.positionSlides = function(move) { var offset = 0; var position = this.position || 0; for(var i = 0;i < this.slides_order.length;i++) { //this.slides[ this.slides_order[i] ].element.css(this.positionAttr,offset+'px'); this.slides[ this.slides_order[i] ].position = offset; offset+= this.width; } if(move) this.controller.changeTo(this.slides[this.index].position,false,0,null, false); } this.changeLoopStart = function() { var firstSlide = this.slides[this.slides_order[0]]; var last = this.slides_order.pop(); var lastSlide = this.slides[last]; this.slides_order.unshift(last); lastSlide.position = firstSlide.position - this[this.dimensionAttr]; var rposition = this.slides[this.index].position; } this.changeLoopEnd = function() { var lastSlide = this.slides[this.slides_order[this.slides_order.length-1]]; var first = this.slides_order.shift(); var firstSlide = this.slides[first]; this.slides_order.push(first); firstSlide.position = firstSlide.position + this[this.dimensionAttr]; } this._updatePosition = function(tcontrol, position) { //this.__updatePosition_.call(this,tcontrol, position); for(var i =0 ;i < this.slides_order.length;i++) { var slide = this.slides[this.slides_order[i]]; var distance = slide.position -position; this.updatePerpective(slide, distance); } } this.updatePerpective = function(slide, distance) { var value = Math.abs(distance / this[this.dimensionAttr]); value = 1 - (value); value < 0? (slide.element.css("opacity", 0)):(slide.element.css("opacity", value)); } },'wave'); var NS = 'stswipe'; var STTouchSwipe = function(element, options) { var touchSwipeDefaults= { // Indicates whether the touch swipe will be enabled touchSwipe: true, // Sets the minimum amount that the slides should move touchSwipeThreshold: 50 } // The x and y coordinates of the pointer/finger's starting position this.touchStartPoint= {x: 0, y: 0}; this.touchTempPoint= {x: 0, y: 0}; // The x and y coordinates of the pointer/finger's end position this.touchEndPoint= {x: 0, y: 0}; // The distance from the starting to the end position on the x and y axis this.touchDistance= {x: 0, y: 0}; this.touchMove= {x: 0, y: 0}; // The position of the slides when the touch swipe starts this.touchStartPosition= 0; // Indicates if the slides are being swiped this.isTouchMoving= false; // Stores the names of the events this.touchSwipeEvents= { startEvent: '', moveEvent: '', endEvent: '' }, this.element = $(element); this.settings = $.extend({}, touchSwipeDefaults,options); this.initTouchSwipe= function() { var that = this; // check if touch swipe is enabled if ( this.settings.touchSwipe === false ) { return; } this.touchSwipeEvents.startEvent = 'touchstart' + '.' + NS + ' mousedown' + '.' + NS; this.touchSwipeEvents.moveEvent = 'touchmove' + '.' + NS + ' mousemove' + '.' + NS; this.touchSwipeEvents.endEvent = 'touchend' + '.' + this.uniqueId + '.' + NS + ' mouseup' + '.' + this.uniqueId + '.' + NS; // Listen for touch swipe/mouse move events this.element.on( this.touchSwipeEvents.startEvent, $.proxy( this._onTouchStart, this ) ); this.element.on( 'dragstart.' + NS, function( event ) { event.preventDefault(); }); // Add the grabbing icon this.element.addClass( 'st-grab' ); }, // Called when the slides starts being dragged this._onTouchStart= function( event ) { // Disable dragging if the element is set to allow selections if ( $( event.target ).closest( '.st-selectable' ).length >= 1 ) { return; } var that = this, eventObject = typeof event.originalEvent.touches !== 'undefined' ? event.originalEvent.touches[0] : event.originalEvent; // Prevent default behavior only for mouse events if ( typeof event.originalEvent.touches === 'undefined' ) { event.preventDefault(); } // Disable click events on links $( event.target ).parents( '.st-slide' ).find( 'a' ).one( 'click.' + NS, function( event ) { event.preventDefault(); }); this.touchStartTime = new Date().getTime(); // Get the initial position of the mouse pointer and the initial position // of the slides' container this.touchStartPoint.x = eventObject.pageX || eventObject.clientX; this.touchStartPoint.y = eventObject.pageY || eventObject.clientY; this.touchTempPoint.x = eventObject.pageX || eventObject.clientX; this.touchTempPoint.y = eventObject.pageY || eventObject.clientY; //this.touchStartPosition = this.view.position; // Clear the previous distance values this.touchDistance.x = this.touchDistance.y = 0; this.touchMove.x = this.touchMove.y = 0; // Listen for move and end events this.element.on( this.touchSwipeEvents.moveEvent, $.proxy( this._onTouchMove, this ) ); $( document ).on( this.touchSwipeEvents.endEvent, $.proxy( this._onTouchEnd, this ) ); // Swap grabbing icons this.element.removeClass( 'st-grab' ).addClass( 'st-grabbing' ); // Add 'sp-swiping' class to indicate that the slides are being swiped //this.$slider.addClass( 'sp-swiping' ); if(this.settings.onTouchStart!=undefined) this.settings.onTouchStart.call(this); }, // Called during the slides' dragging this._onTouchMove= function( event ) { var eventObject = typeof event.originalEvent.touches !== 'undefined' ? event.originalEvent.touches[0] : event.originalEvent; // Indicate that the move event is being fired this.isTouchMoving = true; // Get the current position of the mouse pointer this.touchEndPoint.x = eventObject.pageX || eventObject.clientX; this.touchEndPoint.y = eventObject.pageY || eventObject.clientY; // Calculate the distance of the movement on both axis this.touchDistance.x = this.touchEndPoint.x - this.touchStartPoint.x; this.touchDistance.y = this.touchEndPoint.y - this.touchStartPoint.y; this.touchMove.x = this.touchEndPoint.x - this.touchTempPoint.x; this.touchMove.y = this.touchEndPoint.y - this.touchTempPoint.y; // Calculate the distance of the swipe that takes place in the same direction as the orientation of the slides // and calculate the distance from the opposite direction. // // For a swipe to be valid there should more distance in the same direction as the orientation of the slides. var distance = this.settings.direction === 'h' ? this.touchDistance.x : this.touchDistance.y, oppositeDistance = this.settings.direction === 'h' ? this.touchDistance.y : this.touchDistance.x; var move = this.settings.direction === 'h' ? this.touchMove.x : this.touchMove.y; // If the movement is in the same direction as the orientation of the slides, the swipe is valid if ( Math.abs( distance ) > Math.abs( oppositeDistance ) ) { event.preventDefault(); } else { return; } if(this.settings.onTouchMove!=undefined) this.settings.onTouchMove.call(this,distance,move); //this.view._moveTo( this.touchStartPosition + distance, true ); this.touchTempPoint.x = eventObject.pageX || eventObject.clientX; this.touchTempPoint.y = eventObject.pageY || eventObject.clientY; } // Called when the slides are released this._onTouchEnd= function( event ) { var touchDuration = new Date().getTime() - this.touchStartTime; var that = this, touchDistance = this.settings.direction === 'h' ? this.touchDistance.x : this.touchDistance.y; // this.positionProperty = this.settings.orientation === 'horizontal' ? 'left' : 'top'; // Remove the move and end listeners this.element.off( this.touchSwipeEvents.moveEvent ); $( document ).off( this.touchSwipeEvents.endEvent ); // Swap grabbing icons this.element.removeClass( 'st-grabbing' ).addClass( 'st-grab' ); // Check if there is intention for a tap if ( this.isTouchMoving === false || this.isTouchMoving === true && Math.abs( this.touchDistance.x ) < 10 && Math.abs( this.touchDistance.y ) < 10 ) { // Re-enable click events on links $( event.target ).parents( '.st-slide' ).find( 'a' ).off( 'click.' + NS ); } // Remove the 'sp-swiping' class but with a delay // because there might be other event listeners that check // the existence of this class, and this class should still be // applied for those listeners, since there was a swipe event setTimeout(function() { //that.view.slider.element.removeClass( 'st-swiping' ); }, 1 ); // Return if the slides didn't move if ( this.isTouchMoving === false ) { return; } this.isTouchMoving = false; $( event.target ).parents( '.st-slide' ).one( 'click', function( event ) { event.preventDefault(); }); // Calculate the old position of the slides in order to return to it if the swipe // is below the threshold // var oldSlidesPosition = this.oldSlidesPosition;//parseInt( this.view.slideContainer.find( '.st-slide' ).eq( this.view.selectedSlideIndex ).css( this.view.positionAttr ), 10 ) + this.visibleOffset; if(this.settings.onTouchEnd!=undefined) this.settings.onTouchEnd.call(this,touchDistance,touchDuration); /*if ( Math.abs( touchDistance ) < this.view.options.touchSwipeThreshold ) { this.view._moveTo( oldSlidesPosition ); } else { // Calculate by how many slides the slides container has moved var slideArrayDistance = touchDistance / ( this.view.slide_size + this.view.options.slide_distance ); // Floor the obtained value and add or subtract 1, depending on the direction of the swipe slideArrayDistance = parseInt( slideArrayDistance, 10 ) + ( slideArrayDistance > 0 ? 1 : - 1 ); // Get the index of the currently selected slide and subtract the position index in order to obtain // the new index of the selected slide. var nextSlideIndex = this.view.slides_order[ $.inArray( this.view.selectedSlideIndex, this.view.slides_order ) - slideArrayDistance ]; if ( this.view.options.loop === true ) { this.view.gotoSlide( nextSlideIndex ); } else { if ( typeof nextSlideIndex !== 'undefined' ) { this.view.gotoSlide( nextSlideIndex ); } else { this.view._moveTo( oldSlidesPosition ); } } }*/ }, // Destroy the module this.destroyTouchSwipe= function() { this.element.off( this.touchSwipeEvents.startEvent ); this.element.off( this.touchSwipeEvents.moveEvent ); this.element.off( 'dragstart.' + NS ); $( document ).off( this.touchSwipeEvents.endEvent ); this.element.removeClass( 'st-grab' ); } }; var STSliderSlide = function(element, controller) { this.element_src= $(element); this.slideController = controller; this.layerCount = 0; this.loaded = false; this.bg_loaded = false; this.layer_loaded = false; this.ready = false; this.init = function() { this.bg_src= false; if(this.element_src.data('src') != undefined) { this.bg_src = this.element_src.data('src'); } else { var img = this.element_src.children('img:first'); if(img.data('src') != undefined) this.bg_src = img.data('src'); } this.element = $('<div class="st-slide"/>'); this.view.slideContainer.append(this.element); this.loadBG(); } this.create = function() { this.initLayers(); } this.initLayers = function() { var that =this; this.layerController = new STSliderLayerController(this); this.element_src.children('.st-layer').each(function() { that.addLayer(this); }); this.layerController.initLayers(); } this.addLayer = function(element) { this.layers=this.layers||[]; this.layerController = this.layerController||new STSliderLayerController(this); var layer = this.layerController.addLayer(element); this.layerCount++; return layer; } this.initSize = function() { this.width = this.view.width; this.height = this.view.height; this.element.width(this.width).height(this.height); this.layerController!=undefined && this.layerController.resize(this.view.resize_ratio); } this.loadBG = function() { this.background_container =$('<div class="st-slide-bg"/>'); this.background_container.css('height','100%'); this.element.append(this.background_container); if( this.bg_src) { this.preloadBG(); } else { this.img = this.element_src.children('img:first'); this.background_container.append(this.img); var that = this; if(this.img!= undefined) this.img.one('load', function(event) { that.onBGLoaded(event); }); } } this.onBGLoaded = function(event) { this.bg_img_height = event.height || this.img[0].naturalHeight; this.bg_img_width = event.width || this.img[0].naturalWidth; this.resizeBG(); this.bg_loaded = true; this.layerController.loaded && (this.loaded = this.bg_loaded && this.layer_loaded); this.loaded && this.onLoadComplete(); this.selected && this.layer_loaded && this.layerController.showLayers(); } this.resizeBG = function() { var bg_scale_mode = this.element_src.data('fillMode') != undefined ? this.element_src.data('fillMode'):'cover'; if ( bg_scale_mode === 'cover' ) { if ( (this.bg_img_width / this.bg_img_height) <= (this.width / this.height) ) { this.img.css({ width: '100%', height: 'auto' }); } else { this.img.css({ width: 'auto', height: '100%' }); } } else if ( bg_scale_mode === 'contain' ) { if ( this.bg_img_width / this.bg_img_height >= this.width / this.height ) { this.img.css({ width: '100%', height: 'auto' }); } else { this.img.css({ width: 'auto', height: '100%' }); } } else if ( bg_scale_mode === 'exact' ) { this.img.css({ width: '100%', height: '100%' }); } var centerMode = this.element_src.data('centerMode') != undefined ? this.element_src.data('centerMode'):0; if ( centerMode ) { this.img.css({ 'marginLeft': ( this.img.width() - this.background_container.width() ) * 0.5, 'marginTop': ( this.img.height() - this.background_container.height() ) * 0.5 }); } } this.preloadBG = function() { if( this.bg_src && !this.bg_loaded) { this.img = $('<img/>'); this.background_container.append(this.img); var that = this; this.img.preloadImg(this.bg_src, function(event) { that.onBGLoaded(event); }); } } this.preloadImages = function() { this.preloadBG(); this.layerCount > 0 && this.layerController.loadLayers(this.onLoadLayersComplete, this); this.layerController.loaded && (this.loaded = this.bg_loaded && this.layer_loaded); this.loaded && this.onLoadComplete(); } this.onLoadComplete = function() { this.slideController.startTimer(); this.selected && this.layerController.showLayers(); } this.onLoadLayersComplete = function() { this.layer_loaded =true; this.loaded = this.bg_loaded && this.layer_loaded; this.ready = this.loaded; this.loaded && this.onLoadComplete(); } this.waitToSelect = function() { this.wait_select = true; this.preloadImages(); } this.select = function() { this.wait_select = false; this.selected = true; this.layerCount && this.layerController.showLayers(); } this.deselect = function() { this.wait_select = false; this.selected = false; this.layerCount && this.layerController.hideLayers() } }; var STSliderLayerController = function(slide) { this.slide = slide; this.layers = []; this.preloadCount = 0; this.layerLoadCompleted = !0; this.loaded= false; this.layerToLoad = 0; this.layerAnimating = 0; this.init = function() { this.element = $('<div class="st-layer-container"/>'); this.slide.element.append(this.element); } this.initLayers = function() { for(var i = 0; i< this.layers.length;i++) this.layers[i].init(); } this.loadLayers= function(onlayerLoadCompleted,ref) { this._onlayerLoadCompleted = onlayerLoadCompleted; var that = this; for(var i = 0; i< this.layers.length;i++) this.layers[i].load(function() { that.layerToLoad--; if(that.layerToLoad<=0) { that.loaded = true; onlayerLoadCompleted.call(ref); } }); } this.addLayer= function(layerElement) { layerElement = $(layerElement); var type = layerElement.data('type') || 'text'; var layer = new STSliderLayer.layers[type]; layer.slide = this.slide; layer.layerController = this; layer.element_src = layerElement; this.layers.push(layer); layer.needToPreload && this.preloadCount++; (this.preloadCount > 0) && (this.layerLoadCompleted = !1); this.layerToLoad++; return layer; } this.onLayerLoadCompleted =function() { this.loaded = true; this.layerToLoad--; if(that.layerToLoad<=0) this._onlayerLoadCompleted.call(); } this.showLayers = function() { if(this.loaded) { this.layerAnimating=0; for(var i = 0; i< this.layers.length;i++) { this.layerAnimating++; this.layers[i].show(); } } } this.onLayerAnimateComplete = function(layer) { this.layerAnimating--; } this.hideLayers = function() { for(var i = 0; i< this.layers.length;i++) this.layers[i].hide(); } this.resize = function(ratio) { for(var i = 0; i< this.layers.length;i++) { this.layers[i].resize(ratio); } } this.init(); }; var STSliderLayer = function() { this.needToPreload = !1; this.offsetX=this.offsetY=0; this.responsive_css = ['width','height','font-size','line-height']; this.init = function() { this.show_animation={ duration:1000, delay:3000, params:{opacity:0} }; this.hide_animation = { duration:1000, params:{opacity:1} }; this.needToPreload = false; this.element = this.element_src.clone(); this.element.addClass('st-layer'); this.layerController.element.append(this.element); if(this.element_src.data('id')!=undefined) this.element.attr('id',this.element_src.data('id')); this.element.hide(); this.element.css('visibility', 'hidden'); this.element.hide(); this.is_hidden =true; if(this.element_src.data('position')) { var pos = this.element_src.data('position'); pos = pos.split(','); if(pos.length ==2) this.offsetX=pos[0],this.offsetY=pos[1]; else if(pos.length ==1) this.offsetX=this.offsetY=pos[0]; } this.hAlign = 'top',this.vAlign = 'left'; if(this.element_src.data('align')) { var align = this.element_src.data('align'); align = align.split(' '); if(align.length ==2) this.vAlign=align[1],this.hAlign=align[0]; } if(this.element_src.hasClass('no-animated')) this.show_animation.disabled = true; if(this.element_src.data('duration')) this.show_animation.duration=this.element_src.data('duration'); if(this.element_src.data('easing')) this.show_animation.easing=this.element_src.data('easing'); if(this.element_src.data('delay')) this.show_animation.delay=this.element_src.data('delay'); if(this.element_src.data('transition')) { transition=this.element_src.data('transition'); this.show_animation.params = this.parseTransionParams(transition); } if(this.element_src.data('hide-duration')) this.hide_animation.duration=this.element_src.data('hide-duration'); if(this.element_src.data('hide-delay')) this.hide_animation.delay=this.element_src.data('hide-delay'); if(this.element_src.data('hide-easing')) this.hide_animation.easing=this.element_src.data('hide-easing'); if(this.element_src.data('hide-transition')) { transition=this.element_src.data('hide-transition'); this.hide_animation.params = this.parseTransionParams(transition);; } } this.parseTransionParams = function(s) { var transforms = { rotateX:'deg',rotateY:'deg',rotateZ:'deg', translateX:'px',translateY:'px',translateZ:'px', skewX:'deg',skewY:'deg', scaleX:'',scaleY:'', transformOrigin:'' } var altTransformProp = { translateX:'left',translateY:'top', } var s = s.split(','); var rs = {}; var ttransform = []; var otransform = []; var altiveCss = []; for(var i = 0;i < s.length;i++) { var p = s[i].split(':'); if(p.length==2) { if(transforms[p[0]]!=undefined) { // ttransform.push(p[0] + '('+p[1]+transforms[p[0]]+')'); // otransform.push(p[0] + '(0'+transforms[p[0]]+')'); if(altTransformProp[p[0]]!=undefined) { //altiveCss.push({altTransformProp[p[0]]:(p[1]+'px')}); } } rs[p[0]]=parseFloat(p[1]); } } return rs; } this.setAnimation = function(animationObject) { for(var i in animationObject) { if(!animationObject.hasOwnProperty(i)) continue; if(animationObject[i]!=undefined && animationObject[i]!=null) this.show_animation[i] = animationObject[i]; } } this.setHideAnimation = function(animationObject) { for(var i in animationObject) { if(!animationObject.hasOwnProperty(i)) continue; if(animationObject[i]!=null) this.hide_animation[i] = animationObject[i]; } } this.resize = function(ratio) { } this.setPosition = function() { var x=y=0; var caption_width = this.element.outerWidth(); var slide_width = this.slide.element.width(); var caption_height = this.element.outerHeight(); var slide_height = this.slide.element.height(); switch(this.vAlign) { case 'left': break; case 'right': x = slide_width-caption_width; break; case 'center': x = slide_width/2-caption_width/2; break } switch(this.hAlign) { case 'top': break; case 'bottom': y = slide_height-caption_height; break; case 'center': y = slide_height/2-caption_height/2; break } x = x+this.offsetX; y = y+this.offsetY; this.element.css({left:x+'px',top:y+'px'}); } this.align = function() { } this.show = function() { this.setPosition(); this.element.show(); this.show_animate(); } this.hide = function() { this.element.hide(); //this.element.css('visibility','hidden'); this.show_animate(); } this.onAnimationComplete = function(type) { if(type==1) { this.is_animated = false; this.layerController.onLayerAnimateComplete(this); } else { } } this.show_animate = function() { var start = this.show_animation.params var tween = new ANIMO.Animo(this.element[0], false,this.show_animation.params); tween.reverse(true); tween.duration(2000); tween.easing('exponentialInOut'); tween.delay(1000); var that = this; tween.onStart(function() { that.element.css('visibility',''); }); tween.start(); } this.hide_animate = function() { var tween = new ANIMO.Animo(this.element[0], false,this.hide_animation.params); tween.duration(2000); tween.easing('exponentialInOut'); tween.delay(1000); tween.start(); } this.load = function(onComplete) { if(!this.needToPreload) { this.loaded = true; if(onComplete) onComplete.call(this); } else this.preloadImages(function() { this.load=true; this.layerController.preloadCount--; if(onComplete) onComplete.call(this); }); } this.preloadImages = function(onCompleted) { } }; STSliderLayer.createLayerType = function(type,protype, parentType) { STSliderLayer.layers = STSliderLayer.layers||{}; if(parentType==undefined || parentType=='') parentType = 'text'; if(STSliderLayer.layers[parentType]!=undefined) parentProtype =new STSliderLayer.layers[parentType]; else parentProtype =new STSliderLayer; STSliderLayer.layers[type] = function(){}; STSliderLayer.layers[type].prototype = $.extend({},parentProtype,protype); for(var i in parentProtype) { if(!parentProtype.hasOwnProperty(i)) continue; if(STSliderLayer.layers[type].prototype.hasOwnProperty(i)) STSliderLayer.layers[type].prototype['_' + i+'_'] = parentProtype[i]; } } STSliderLayer.createLayerType('text',function() { }); STSliderLayer.createLayerType('image',function() { this.needToPreload = true; this.preloadImages = function() { } }); $.fn.stslider = function(options) { return this.each(function(key, value){ var element = $(this); if (element.data('stslider')) { return element.data('stslider'); } var slider = new STSlider(this, options); slider.setupSlide(); element.data('stslider', slider); }); }; /** * ANIMO.js - Licensed under the MIT license * https://github.com/dalisoft/animo.js * * Original copy of this tweening engine is open-source * https://github.com/sole/tween.js * Copyright (c) 2015 @sole (Source author), @dalisoft (Modified author). All right reserved */ // IE 8 Date.now = (Date.now || function () { return new Date().getTime(); }); function R(b, a) { var d = {}, e = b.replace(/, | ,| , /g, ",").split(" "); if (b && "" !== b) for (var f = 0; f < e.length; f++) { var c = e[f].match(/([a-zA-z0-9]+)\(/g)[0].replace(/\(|\)/g, ""), h = e[f].match(/\((.*)\)/g)[0].replace(/\(|\)/g, ""); d[c] = a ? parseFloat(h.match(/([0-9]+)/g)[0], 10) : h } return d } /*! @name CSSImploder @version v1 build 3680 @description Mostly used for styling element or animation @author @dalisoft, https://github.com/dalisoft @copyright (c) 2015, @dalisoft. All right reserved @license MIT-License, https://bit.ly/mit-license */ function each(arr, fn) { 'use strict'; var i; if (Array.isArray(arr)) { for (i = 0; i < arr.length; i++) { fn(i, arr[i]); } } else { for (i in arr) { fn(i, arr[i]); } } } function CSSImploder(input) { 'use strict'; var units = { rotate : "deg", rotateX : "deg", rotateY : "deg", rotateZ : "deg", scaleX : "", scaleY : "", scaleZ : "", x : "px", y : "px", z : "px", skewX : "deg", skewY : "deg", width : "px", height : "px", top : "px", left : "px", right : "px", bottom : "px", marginLeft : "px", marginTop : "px", marginRight : "px", marginBottom : "px", paddingLeft : "px", paddingTop : "px", paddingRight : "px", paddingBottom : "px", blur : "px", "hue-rotate" : "deg" }, style = {}, transform = '', filter = '', transform_array = [], filter_array = []; /* Transform Coding area */ transform_array = ['rotate', 'rotateX', 'rotateY', 'rotateZ', 'translate', 'translateX', 'translateY', 'translateZ', 'translate3d', 'skewX', 'skewY', 'scale', 'scaleX', 'scaleY', 'scaleZ', 'x', 'y', 'z']; each(transform_array, function (i, value) { var t = value, xyz, val = input[t], tr = 'translate'; val = typeof val === "string" ? val.replace(/center/, '50%').replace(/top|left/g, '0%').replace(/bottom|right/g, '100%') : val; if (val !== undefined) { if (t === 'x' || t === 'y') { if(input.hasOwnProperty('x')) input.x += typeof input.x === "number" ? units[t] : ''; if(input.hasOwnProperty('y')) input.y += typeof input.y === "number" ? units[t] : ''; if(input.hasOwnProperty('z')) input.z += typeof input.z === "number" ? units[t] : ''; tr += input.hasOwnProperty('z') ? '3d(' : '('; tr += (input.x || '0px') + ', ' + (input.y || '0px') + ''; tr += input.hasOwnProperty('z') ? ', ' + input.z + ')' : ')'; input[t] = undefined; if ( !/translate/g.test(transform) ) { transform += tr + ' '; } } else if ( t !== 'z' ) { if (typeof val === "number" && units[t]) { val = val + units[t]; } transform += t + '(' + val + ') '; } } }); if (transform !== "") { style.transform = transform; } /* End Transform Coding area */ /* Filter Coding area */ filter_array = ['grayscale', 'brightness', 'sepia', 'invert', 'saturate', 'contrast', 'blur', 'hue-rotate', 'drop-shadow']; each(filter_array, function (i, value) { var t = value, val = input[t]; val = typeof val === "string" ? val.replace(/center/, '50%').replace(/top|left/g, '0%').replace(/bottom|right/g, '100%') : val; if (val !== undefined) { if (typeof val === "number" && units[t]) { val = val + units[t]; } filter += t + '(' + val + ') '; } input[t] = undefined; }); if (filter !== "") { style.Filter = filter; } /* End Filter Coding area */ /* Other Coding */ each(input, function (key) { var val = input[key]; val = typeof val === "string" ? val.replace(/center/, '50%').replace(/top|left/g, '0%').replace(/bottom|right/g, '100%') : val; if (typeof val === "number" && units[key]) { val = val + units[key]; } if (process(val)) { style[key] = val; } }); /* End Other Coding */ return style; } function process(val) { return val !== undefined && val !== null && val !== "" && val !== "undefined"; } function cubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) { var ax = 0, bx = 0, cx = 0, ay = 0, by = 0, cy = 0; function sampleCurveX(t) { return ((ax * t + bx) * t + cx) * t; } function sampleCurveY(t) { return ((ay * t + by) * t + cy) * t; } function sampleCurveDerivativeX(t) { return (3.0 * ax * t + 2.0 * bx) * t + cx; } function solveEpsilon(duration) { return 1.0 / (200.0 * duration); } function solve(x, epsilon) { return sampleCurveY(solveCurveX(x, epsilon)); } function fabs(n) { if (n >= 0) { return n; } else { return 0 - n; } } function solveCurveX(x, epsilon) { var t0, t1, t2, x2, d2, i; for (t2 = x, i = 0; i < 8; i++) { x2 = sampleCurveX(t2) - x; if (fabs(x2) < epsilon) { return t2; } d2 = sampleCurveDerivativeX(t2); if (fabs(d2) < 1e-6) { break; } t2 = t2 - x2 / d2; } t0 = 0.0; t1 = 1.0; t2 = x; if (t2 < t0) { return t0; } if (t2 > t1) { return t1; } while (t0 < t1) { x2 = sampleCurveX(t2); if (fabs(x2 - x) < epsilon) { return t2; } if (x > x2) { t0 = t2; } else { t1 = t2; } t2 = (t1 - t0) * 0.5 + t0; } return t2; } cx = 3.0 * p1x; bx = 3.0 * (p2x - p1x) - cx; ax = 1.0 - cx - bx; cy = 3.0 * p1y; by = 3.0 * (p2y - p1y) - cy; ay = 1.0 - cy - by; return solve(t, solveEpsilon(duration)); } function getCubicBezierTransition(x1, y1, x2, y2) { return function (pos) { return cubicBezierAtTime(pos, x1, y1, x2, y2, 1); }; } function pre(prop, prefix) { var div = document.createElement('div'); // Handle unprefixed versions (FF16+, for example) if (prop in div.style || prop in div) { return prop; } var prefixes = ['Moz', 'Webkit', 'O', 'Ms', 'ms']; var prop_ = prop.charAt(0).toUpperCase() + prop.substr(1); for (var i = 0; i < prefixes.length; ++i) { var vendorProp = prefixes[i] + prop_; if (vendorProp in div.style || vendorProp in div) { if (prefix) { return prefixes[i]; } return vendorProp; } } div = undefined; return false; } var ANIMO = ANIMO || (function () { var _animos = []; return { VERSION : [0, 9, 7], getAll : function () { return _animos; }, support : { transform3d : pre('perspective') }, //process easing 31 EaseString : function (e) { if (e === 'linear') return ANIMO.Easing.Linear.None; if (e === 'quadraticIn') return ANIMO.Easing.Quadratic.In; if (e === 'quadraticOut') return ANIMO.Easing.Quadratic.Out; if (e === 'quadraticInOut') return ANIMO.Easing.Quadratic.InOut; if (e === 'cubicIn') return ANIMO.Easing.Cubic.In; if (e === 'cubicOut') return ANIMO.Easing.Cubic.Out; if (e === 'cubicInOut') return ANIMO.Easing.Cubic.InOut; if (e === 'quarticIn') return ANIMO.Easing.Quartic.In; if (e === 'quarticOut') return ANIMO.Easing.Quartic.Out; if (e === 'quarticInOut') return ANIMO.Easing.Quartic.InOut; if (e === 'quinticIn') return ANIMO.Easing.Quintic.In; if (e === 'quinticOut') return ANIMO.Easing.Quintic.Out; if (e === 'quinticInOut') return ANIMO.Easing.Quintic.InOut; if (e === 'sinusoidalIn') return ANIMO.Easing.Sinusoidal.In; if (e === 'sinusoidalOut') return ANIMO.Easing.Sinusoidal.Out; if (e === 'sinusoidalInOut') return ANIMO.Easing.Sinusoidal.InOut; if (e === 'exponentialIn') return ANIMO.Easing.Exponential.In; if (e === 'exponentialOut') return ANIMO.Easing.Exponential.Out; if (e === 'exponentialInOut') return ANIMO.Easing.Exponential.InOut; if (e === 'circularIn') return ANIMO.Easing.Circular.In; if (e === 'circularOut') return ANIMO.Easing.Circular.Out; if (e === 'circularInOut') return ANIMO.Easing.Circular.InOut; if (e === 'elasticIn') return ANIMO.Easing.Elastic.In; if (e === 'elasticOut') return ANIMO.Easing.Elastic.Out; if (e === 'elasticInOut') return ANIMO.Easing.Elastic.InOut; if (e === 'backIn') return ANIMO.Easing.Back.In; if (e === 'backOut') return ANIMO.Easing.Back.Out; if (e === 'backInOut') return ANIMO.Easing.Back.InOut; if (e === 'bounceIn') return ANIMO.Easing.Bounce.In; if (e === 'bounceOut') return ANIMO.Easing.Bounce.Out; if (e === 'bounceInOut') return ANIMO.Easing.Bounce.InOut; //default return ANIMO.Easing.Exponential.InOut; }, match : function (arr, m) { var fix = m.test(arr[i]); // fix MSIE issue var value = -1; for (var i = 0; i < arr.length; i++) { if (m.test(arr[i])) { value = i; } } return value; }, String : function (a, b, relative, relativeType) { if (typeof b === "number" && typeof a === "number") { b += a; return function (n) { return a + (b - a) * n; } } var number = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, string = [], keys = [], from = [], to = [], pos = [], cursor = 0, m; while (m = number.exec(a)) { var fromM = parseFloat(m[0], 10); from.push(fromM); } while (m = number.exec(b)) { if (m.index > cursor) { string.push(b.slice(cursor, m.index)); } var toM = parseFloat(m[0], 10), rv = m[0].charAt(0); rv = /\+|-|\/*\/|\//g.test(rv) ? rv : false; if ( relative ) { if ( relativeType === '+' ) { toM += fromM; } else if ( relativeType === '-' ) { toM -= fromM; } } to.push(toM); keys.push(string.length); string.push(null); cursor = number.lastIndex; } if (cursor < b.length) { string.push(b.slice(cursor)); } return function (n) { for (var i = 0; i < keys.length; i++) { var isColorIndex = ANIMO.match(string, /color/g), isColor = isColorIndex === -1 ? null : string[isColorIndex]; pos[i] = from[i] + (to[i] - from[i]) * n; if (isColor !== null) { pos[i] = Math.round(pos[i]); } string[keys[i]] = pos[i]; } return string.join(''); } }, removeAll : function () { _animos = []; }, add : function (ANIMO) { _animos.push(ANIMO); }, remove : function (ANIMO) { var i = _animos.indexOf(ANIMO); if (i !== -1) { _animos.splice(i, 1); } }, CSSPlugin : { getStyle : function (a, d, e) { var f = {}, c, b; if (window.getComputedStyle) b = getComputedStyle(a); else { b = {}; var g = a.currentStyle, q; for (q in g) b.hasOwnProperty(q) || (b[q] = g[q]); b.x = 0; b.y = 0; b.rotate = 0; b.opacity = parseFloat(/alpha\(opacity=([0-9]+)\)/.test(b.filter) ? b.filter.match(/alpha\(opacity=([0-9]+)\)/)[1] : 100, 10) / 100; } for (c in d) { g = { width : a.offsetWidth + 'px', height : a.offsetHeight + 'px', top : a.offsetTop + 'px', left : a.offsetLeft + 'px', scroll : a.scroll, scrollTop : a.scrollTop, scrollLeft : a.scrollLeft }; f[c] = /width|height|top|left|scroll|scrollTop|scrollLeft/.test(c) ? g[c] : b[c]; if ( f[c] === undefined ) { f[c] = 0; } if (e) f[c] = parseFloat(f[c], 10); } return f }, setStyle : function (e, a) { var el = e, sty = el.style, key, value; for (key in a) { value = a[key]; if (/scroll/g.test(key)) { el[key] = value; } else { sty[key] = value; } } /*===== Performance optimize, clean completed values =====*/ el = undefined; sty = undefined; _valuesStart = undefined; _valuesEnd = undefined; _object = undefined; } }, color : { hexToRgb : function (hex) { // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") var shr = /^#?([a-f\d])([a-f\d])([a-f\d])$/i; hex = hex.replace(shr, function (m, r, g, b) { return r + r + g + g + b + b; }); var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); return result ? { r : parseInt(result[1], 16), g : parseInt(result[2], 16), b : parseInt(result[3], 16) } : null; }, parse : function (c) { if (typeof c === "string" && /#/i.test(c)) { return 'rgb(' + [ANIMO.color.hexToRgb(c).r, ANIMO.color.hexToRgb(c).g, ANIMO.color.hexToRgb(c).b].join(",") + ')'; } } }, update : function (time) { if (_animos.length === 0) return false; var i = 0; time = time !== undefined ? time : window.performance.now(); while (i < _animos.length) { if (_animos[i].update(time)) { i++; } else { _animos.splice(i, 1); } } return true; } }; })(); ANIMO.Animo = function (node, object, end) { var _cssPlugin = ANIMO.CSSPlugin; var _setStyle = _cssPlugin.setStyle; var _getStyle = _cssPlugin.getStyle; var _string = ANIMO.String; var _rand = Math.random(); var _node = typeof node === "string" ? document.querySelector(node) : Array.isArray(node) ? node[0] : node; var _object = CSSImploder(object || _getStyle(_node, end, true)); var _valuesStart = _object; var _valuesEnd = CSSImploder(end || _getStyle(_node, _object, true)); var _valuesStartRepeat = {}; var _duration = 1000; var _repeat = 0; var _yoyo = false; var _isPlaying = false; var _reversed = false; var _delayTime = 0; var _startTime = null; var _easingFunction = ANIMO.Easing.Linear.None; var _chainedANIMOs = []; var _onStartCallback = null; var _onStartCallbackFired = false; var _onUpdateCallback = null; var _onCompleteCallback = null; var _onQueueFinishedCallback = null; var _onStopCallback = null; var _reverse = false; var _timeScale = 1; var _repeatDelay = 0; var _paused = false; var _pauseStart = null; var _now = Date.now(); this.nodes = _node; this.reverse = function (state) { _reverse = state || true; return this; }; this.timeScale = function (scale) { _timeScale = scale; return this; }; this.repeatDelay = function (amount) { _repeatDelay = amount; return this; }; this.duration = function (duration) { _duration = duration; return this; }; this.delay = function (amount) { _delayTime = amount; return this; }; this.repeat = function (times) { _repeat = times; return this; }; this.yoyo = function (yoyo) { _yoyo = yoyo; return this; }; this.pause = function () { if (_paused) { return; } _paused = true; _pauseStart = Date.now(); ANIMO.remove(this); return this; }; this.play = this.resume = function () { if (!_paused) { return; } _paused = false; _now = Date.now(); _startTime += _now - _pauseStart; ANIMO.add(this); return this; }; this.start = function (time) { ANIMO.add(this); _isPlaying = true; _onStartCallbackFired = false; _startTime = time !== undefined ? time : window.performance.now(); _startTime += _delayTime; for (var property in _valuesEnd) { _valuesStartRepeat[property] = _valuesStart[property] || 0; } return this; }; this.stop = function () { if (!_isPlaying) { return this; } ANIMO.remove(this); _isPlaying = false; if (_onStopCallback !== null) { _onStopCallback.call(_object); } this.stopChainedANIMOs(); return this; }; this.stopChainedANIMOs = function () { for (var i = 0, numChainedANIMOs = _chainedANIMOs.length; i < numChainedANIMOs; i++) { _chainedANIMOs[i].stop(); } }; this.delay = function (amount) { _delayTime = amount; return this; }; this.repeat = function (times) { _repeat = times; return this; }; this.yoyo = function (yoyo) { _yoyo = yoyo; return this; }; this.easing = function (easing) { _easingFunction = typeof easing === "string" ? ANIMO.EaseString(easing) : easing; return this; }; this.chain = function () { _chainedANIMOs = arguments; return this; }; this.onStart = function (callback) { _onStartCallback = callback; return this; }; this.onUpdate = function (callback) { _onUpdateCallback = callback; return this; }; this.onComplete = function (callback) { _onCompleteCallback = callback; return this; }; this.onFinished = function (callback) { _onQueueFinishedCallback = callback; return this; }; this.onStop = function (callback) { _onStopCallback = callback; return this; }; this.update = function (time) { var property; if (time < _startTime) { return true; } if (_onStartCallbackFired === false) { if (_onStartCallback !== null) { _onStartCallback.call(_object); } _onStartCallbackFired = true; } time += _rand; var elapsed = (time - _startTime) / (_duration * _timeScale); elapsed = elapsed > 1 ? 1 : elapsed; var value = _easingFunction(elapsed); for (property in _valuesEnd) { if (property) { var start = _reverse ? _valuesEnd[property] : _valuesStart[property] || 0; var end = _reverse ? _valuesStart[property] : _valuesEnd[property] || 0; var relative = false; var relativeType = '+'; if ( /\+/g.test(end) ) { relative = true; relativeType = '+'; } else if ( /\-/g.test(end) ) { relative = true; relativeType = '-'; } var style = _string(start, end, relative, relativeType)(value), filter = pre('Filter', true), sty = {}; /*===== Performance optimize, clean completed values =====*/ start = undefined; end = undefined; property = property === 'Filter' ? filter : pre(property); if (property) { sty[property] = style; } _setStyle(_node, sty); } } if (_onUpdateCallback !== null) { _onUpdateCallback.call(sty, value); } if (elapsed == 1) { if (_repeat > 0) { if (isFinite(_repeat)) { _repeat--; } // reassign starting values, restart by making startTime = now for (property in _valuesStartRepeat) { if (typeof(_valuesEnd[property]) === "string") { _valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property], 10); } if (_yoyo) { var tmp = _valuesStartRepeat[property]; _valuesStartRepeat[property] = _valuesEnd[property]; _valuesEnd[property] = tmp; } _valuesStart[property] = _valuesStartRepeat[property]; } if (_yoyo) { _reversed = !_reversed; } _startTime = time + _delayTime; _startTime += _repeatDelay; return true; } else { if (_onCompleteCallback !== null) { _onCompleteCallback.call(sty); } if (_onQueueFinishedCallback !== null) { _onQueueFinishedCallback(); } _valuesEnd = undefined; _valuesStart = undefined; _object = undefined; for (var i = 0, numChainedANIMOs = _chainedANIMOs.length; i < numChainedANIMOs; i++) { _chainedANIMOs[i].start(time); } return false; } } return true; }; }; ANIMO.raf = function (time) { requestAnimationFrame(ANIMO.raf); ANIMO.update(time); }; ANIMO.Easing = { Linear : { None : function (k) { return k; } }, Quadratic : { In : function (k) { return k * k; }, Out : function (k) { return k * (2 - k); }, InOut : function (k) { if ((k *= 2) < 1) return 0.5 * k * k; return - 0.5 * (--k * (k - 2) - 1); } }, Cubic : { In : function (k) { return k * k * k; }, Out : function (k) { return --k * k * k + 1; }, InOut : function (k) { if ((k *= 2) < 1) return 0.5 * k * k * k; return 0.5 * ((k -= 2) * k * k + 2); } }, Quartic : { In : function (k) { return k * k * k * k; }, Out : function (k) { return 1 - (--k * k * k * k); }, InOut : function (k) { if ((k *= 2) < 1) return 0.5 * k * k * k * k; return - 0.5 * ((k -= 2) * k * k * k - 2); } }, Quintic : { In : function (k) { return k * k * k * k * k; }, Out : function (k) { return --k * k * k * k * k + 1; }, InOut : function (k) { if ((k *= 2) < 1) return 0.5 * k * k * k * k * k; return 0.5 * ((k -= 2) * k * k * k * k + 2); } }, Sinusoidal : { In : function (k) { return 1 - Math.cos(k * Math.PI / 2); }, Out : function (k) { return Math.sin(k * Math.PI / 2); }, InOut : function (k) { return 0.5 * (1 - Math.cos(Math.PI * k)); } }, Exponential : { In : function (k) { return k === 0 ? 0 : Math.pow(1024, k - 1); }, Out : function (k) { return k === 1 ? 1 : 1 - Math.pow(2, - 10 * k); }, InOut : function (k) { if (k === 0) return 0; if (k === 1) return 1; if ((k *= 2) < 1) return 0.5 * Math.pow(1024, k - 1); return 0.5 * ( - Math.pow(2, - 10 * (k - 1)) + 2); } }, Circular : { In : function (k) { return 1 - Math.sqrt(1 - k * k); }, Out : function (k) { return Math.sqrt(1 - (--k * k)); }, InOut : function (k) { if ((k *= 2) < 1) return - 0.5 * (Math.sqrt(1 - k * k) - 1); return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1); } }, Elastic : { In : function (k) { var s, a = 0.1, p = 0.4; if (k === 0) return 0; if (k === 1) return 1; if (!a || a < 1) { a = 1; s = p / 4; } else s = p * Math.asin(1 / a) / (2 * Math.PI); return - (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p)); }, Out : function (k) { var s, a = 0.1, p = 0.4; if (k === 0) return 0; if (k === 1) return 1; if (!a || a < 1) { a = 1; s = p / 4; } else s = p * Math.asin(1 / a) / (2 * Math.PI); return (a * Math.pow(2, - 10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1); }, InOut : function (k) { var s, a = 0.1, p = 0.4; if (k === 0) return 0; if (k === 1) return 1; if (!a || a < 1) { a = 1; s = p / 4; } else s = p * Math.asin(1 / a) / (2 * Math.PI); if ((k *= 2) < 1) return - 0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p)); return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1; } }, Back : { In : function (k) { var s = 1.70158; return k * k * ((s + 1) * k - s); }, Out : function (k) { var s = 1.70158; return --k * k * ((s + 1) * k + s) + 1; }, InOut : function (k) { var s = 1.70158 * 1.525; if ((k *= 2) < 1) return 0.5 * (k * k * ((s + 1) * k - s)); return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2); } }, Bounce : { In : function (k) { return 1 - ANIMO.Easing.Bounce.Out(1 - k); }, Out : function (k) { if (k < (1 / 2.75)) { return 7.5625 * k * k; } else if (k < (2 / 2.75)) { return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75; } else if (k < (2.5 / 2.75)) { return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375; } else { return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375; } }, InOut : function (k) { if (k < 0.5) return ANIMO.Easing.Bounce.In(k * 2) * 0.5; return ANIMO.Easing.Bounce.Out(k * 2 - 1) * 0.5 + 0.5; } }, SteppedEase : { config : function (steps) { return function (k) { return Math.floor(k * steps) / steps; } } }, Bezier : function (x1, y1, x2, y2) { var cubicBezierTransition = getCubicBezierTransition(x1, y1, x2, y2); cubicBezierTransition.x1 = x1; cubicBezierTransition.y1 = y1; cubicBezierTransition.x2 = x2; cubicBezierTransition.y2 = y2; return cubicBezierTransition; } }; ANIMO.Easing.SlowMo = ANIMO.Easing.Bezier(1, 0, 0, 1); ANIMO.Easing.Sprify = ANIMO.Easing.Bezier(1, 1, - .3, 1); ANIMO.Easing.Shafe = ANIMO.Easing.Bezier(1, .5, - .5, 1.5); // UMD (Universal Module Definition) (function (root) { if (typeof define === 'function' && define.amd) { // AMD define([], function () { return ANIMO; }); } else if (typeof exports === 'object') { // Node.js module.exports = ANIMO; } else { // Global variable root.ANIMO = ANIMO; } ANIMO.raf(); })(this);
[+]
..
[-] uninstall.php
[edit]
[-] masterslider.flickr.min.js
[edit]
[-] jquery-1.10.2.min.js
[edit]
[-] masterslider.min - Copy.js
[edit]
[-] masterslider.min.js
[edit]
[-] masterslider.lite.min.js.map
[edit]
[-] masterslider.min - Copy (2).js
[edit]
[-] masterslider.min.js.map
[edit]
[-] jquery.easing.min.js
[edit]
[-] master-slider.php
[edit]
[-] index.php
[edit]
[-] README.txt
[edit]
[-] blank.gif
[edit]
[-] public.js
[edit]
[-] stslider.js
[edit]
[-] masterslider.js
[edit]
[-] masterslider.map
[edit]