-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.easyfader.swipe.min.js
12 lines (11 loc) · 1.39 KB
/
jquery.easyfader.swipe.min.js
1
2
3
4
5
6
7
8
9
10
11
12
/*
* EASYFADER - "SWIPE" EXTENSION
* Version: 1.0.1
* License: Creative Commons Attribution 3.0 Unported - CC BY 3.0
* http://creativecommons.org/licenses/by/3.0/
* This software may be used freely on commercial and non-commercial projects with attribution to the author/copyright holder.
* Author: Patrick Kunka
* Copyright 2013 Patrick Kunka, All Rights Reserved
*/
(function(l){"function"===typeof EasyFader?l.extend(EasyFader.prototype.handlers,{swipe:function(){var b=this,m=l("body"),h=!1,e=!1,n,f,p,g,q,r,c,k=!0;b.$container.on("touchstart",function(a){h=!0;a=a.originalEvent.touches[0]||a.originalEvent.changedTouches[0];n=a.pageX;f=a.pageY});m.on("touchmove",function(a){if(!b.changing&&h){b.pause();var d=a.originalEvent.touches[0]||a.originalEvent.changedTouches[0];p=d.pageX;c=p-n;q=0<c?-c:c;k?(g=d.pageY,k=!1,r=0<g-f?-(g-f):g-f,angle=1*(r/q).toFixed(1),console.info(angle),
3>angle&&angle!==Number.NEGATIVE_INFINITY&&(a.preventDefault(),e=!0)):"carousel"==b.effect&&e&&(a=b.getPrefixedCSS("transform","translateX("+c+"px)"),b.$scrollWrapper.css(a))}});m.on("touchend",function(a){if(e){e=h=!1;if("carousel"==b.effect){a=b.$slides.eq(0).outerWidth(b.includeMargin);var d=-(c/a),d=0>d?Math.floor(d):Math.ceil(d);b.preOffset=a*d+c;a=(b.activeIndex+d)%b.totalSlides;a=0>a?b.totalSlides+a:a}else a=15<c?"prev":-15>c?"next":!1;!1!==a&&b.changeSlides(a)}k=!0})}}):console.error("EasyFader core not found")})(jQuery);