Swiper autoplay smooth

This will be integrated into the default code at some point in the future after we've done more testing, but for now, you can export a Slider with swipe enabled and attach the following code as a .js file in the Resources section of the in5 dialog to create a "smooth" swipe:

$[function[]{
$["#container"].swipe["destroy"];
var pageWidth = parseInt[$[".page"].width[]];
var pageChangeThreshold = pageWidth*.33;
var pageWrap = $['.pages'], startPos, vertMode = false,
nextProp = 'left', backProp = 'right', moveProp = 'left';
var cancelSwipe = function[]{
pageWrap.animate[{left:startPos+'px'},'fast'];
};
$["#container"].swipe[{
allowPageScroll: [vertMode ? 'horizontal' : 'vertical'],
fingers:1,
excludedElements:$.fn.swipe.defaults.excludedElements+',.mejs-overlay-button,map,[ title],[data-useswipe="1"],[data-tapstart="1"], .panzoom,.scroll-horiz',
swipeStatus:function[event, phase, direction, distance, duration, fingers] {
switch[phase]{
case 'start':
startPos = parseInt[pageWrap.css[moveProp]];
break;
case 'end':
if[distance > pageChangeThreshold]{
switch[direction]{
case nextProp:
if[nav.current < nav.numPages] nav.next[];
else cancelSwipe[];
break;
case backProp:
if[nav.current > 1] nav.back[];
else cancelSwipe[];
break;
}
} else {
cancelSwipe[];
}
break;
case 'move':
switch[direction]{
case nextProp:
pageWrap.css[moveProp, [startPos-distance]+'px'];
break;
case backProp:
pageWrap.css[moveProp, [startPos+distance]+'px'];
break;
}
break;
case 'cancel':
cancelSwipe[];
break;
}
},
threshold:4,
maxTimeThreshold:9000
}];
}]

Video liên quan

Chủ Đề