Socket
Socket
Sign inDemoInstall

swipe-js-iso

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.3 to 2.1.4

12

package.json
{
"name": "swipe-js-iso",
"version": "2.1.3",
"main": "swipe.js",
"version": "2.1.4",
"main": "./swipe.js",
"scripts": {
"build": "npm run build:prod && npm run build:dev",
"build:prod": "NODE_ENV=production webpack --config webpack.config --colors",
"build:dev": "webpack --config webpack.config --colors",
"build": "uglifyjs -m reserved=[\"Swipe\"] -o ./swipe.min.js ./swipe.js ",
"prepublishOnly": "npm run build"

@@ -30,5 +28,3 @@ },

"pretty-quick": "^1.8.0",
"uglifyjs-webpack-plugin": "^2.0.1",
"webpack": "^4.26.0",
"webpack-cli": "^3.1.2"
"uglify-js": "^3.4.9"
},

@@ -35,0 +31,0 @@ "engines": {

@@ -1,612 +0,525 @@

(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["Swipe"] = factory();
else
root["Swipe"] = factory();
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js");
/******/ })
/************************************************************************/
/******/ ({
/*
* Swipe 2.0.0
* Brad Birdsall
* https://github.com/thebird/Swipe
* Copyright 2013-2015, MIT License
*
*/
/***/ "./src/index.js":
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports) {
(function(root, factory) {
if (typeof module !== 'undefined' && module.exports) {
module.exports = factory();
} else {
root.Swipe = factory();
}
})(this, function() {
'use strict';
function Swipe(container, options) {
// utilities
var noop = function() {}; // simple no operation function
var offloadFn = function(fn) {
setTimeout(fn || noop, 0);
}; // offload a functions execution
return function Swipe(container, options) {
// utilities
var noop = function() {}; // simple no operation function
var offloadFn = function(fn) {
setTimeout(fn || noop, 0);
}; // offload a functions execution
// check browser capabilities
var browser = {
addEventListener: !!window.addEventListener,
touch:
'ontouchstart' in window ||
(window.DocumentTouch && document instanceof window.DocumentTouch),
transitions: (function(temp) {
var props = [
'transitionProperty',
'WebkitTransition',
'MozTransition',
'OTransition',
'msTransition'
];
for (var i in props) if (temp.style[props[i]] !== undefined) return true;
return false;
})(document.createElement('swipe'))
};
// check browser capabilities
var browser = {
addEventListener: !!window.addEventListener,
touch:
'ontouchstart' in window ||
(window.DocumentTouch && document instanceof window.DocumentTouch),
transitions: (function(temp) {
var props = [
'transitionProperty',
'WebkitTransition',
'MozTransition',
'OTransition',
'msTransition'
];
for (var i in props)
if (temp.style[props[i]] !== undefined) return true;
return false;
})(document.createElement('swipe'))
};
// quit if no root element
if (!container) return;
var element = container.children[0];
var slides, slidePos, width, length;
options = options || {};
var index = parseInt(options.startSlide, 10) || 0;
var speed = options.speed || 300;
var continuous = (options.continuous =
options.continuous !== undefined ? options.continuous : true);
// quit if no root element
if (!container) return;
var element = container.children[0];
var slides, slidePos, width, length;
options = options || {};
var index = parseInt(options.startSlide, 10) || 0;
var speed = options.speed || 300;
var continuous = (options.continuous =
options.continuous !== undefined ? options.continuous : true);
function setup() {
// cache slides
slides = element.children;
length = slides.length;
function setup() {
// cache slides
slides = element.children;
length = slides.length;
// set continuous to false if only one slide
continuous = slides.length < 2 ? false : options.continuous;
// set continuous to false if only one slide
continuous = slides.length < 2 ? false : options.continuous;
// create an array to store current positions of each slide
slidePos = new Array(slides.length);
// create an array to store current positions of each slide
slidePos = new Array(slides.length);
// determine width of each slide
width = Math.round(
container.getBoundingClientRect().width || container.offsetWidth
);
// determine width of each slide
width = Math.round(
container.getBoundingClientRect().width || container.offsetWidth
);
element.style.width = slides.length * width + 'px';
element.style.width = slides.length * width + 'px';
// stack elements
var pos = slides.length;
while (pos--) {
var slide = slides[pos];
// stack elements
var pos = slides.length;
while (pos--) {
var slide = slides[pos];
slide.style.width = width + 'px';
slide.setAttribute('data-index', pos);
slide.style.width = width + 'px';
slide.setAttribute('data-index', pos);
if (browser.transitions) {
slide.style.left = pos * -width + 'px';
move(pos, index > pos ? -width : index < pos ? width : 0, 0);
if (browser.transitions) {
slide.style.left = pos * -width + 'px';
move(pos, index > pos ? -width : index < pos ? width : 0, 0);
}
}
// reposition elements before and after index
if (continuous && browser.transitions) {
move(circle(index - 1), -width, 0);
move(circle(index + 1), width, 0);
}
if (!browser.transitions) element.style.left = index * -width + 'px';
container.style.visibility = 'visible';
}
// reposition elements before and after index
if (continuous && browser.transitions) {
move(circle(index - 1), -width, 0);
move(circle(index + 1), width, 0);
function prev() {
if (continuous) slide(index - 1);
else if (index) slide(index - 1);
}
if (!browser.transitions) element.style.left = index * -width + 'px';
function next() {
if (continuous) slide(index + 1);
else if (index < slides.length - 1) slide(index + 1);
}
container.style.visibility = 'visible';
}
function circle(index) {
// a simple positive modulo using slides.length
return (slides.length + (index % slides.length)) % slides.length;
}
function prev() {
if (continuous) slide(index - 1);
else if (index) slide(index - 1);
}
function slide(to, slideSpeed) {
// do nothing if already on requested slide
if (index == to) return;
function next() {
if (continuous) slide(index + 1);
else if (index < slides.length - 1) slide(index + 1);
}
if (browser.transitions) {
var direction = Math.abs(index - to) / (index - to); // 1: backward, -1: forward
function circle(index) {
// a simple positive modulo using slides.length
return (slides.length + (index % slides.length)) % slides.length;
}
// get the actual position of the slide
if (continuous) {
var natural_direction = direction;
direction = -slidePos[circle(to)] / width;
function slide(to, slideSpeed) {
// do nothing if already on requested slide
if (index == to) return;
// if going forward but to < index, use to = slides.length + to
// if going backward but to > index, use to = -slides.length + to
if (direction !== natural_direction)
to = -direction * slides.length + to;
}
if (browser.transitions) {
var direction = Math.abs(index - to) / (index - to); // 1: backward, -1: forward
var diff = Math.abs(index - to) - 1;
// get the actual position of the slide
if (continuous) {
var natural_direction = direction;
direction = -slidePos[circle(to)] / width;
// move all the slides between index and to in the right direction
while (diff--)
move(
circle((to > index ? to : index) - diff - 1),
width * direction,
0
);
// if going forward but to < index, use to = slides.length + to
// if going backward but to > index, use to = -slides.length + to
if (direction !== natural_direction)
to = -direction * slides.length + to;
}
to = circle(to);
var diff = Math.abs(index - to) - 1;
move(index, width * direction, slideSpeed || speed);
move(to, 0, slideSpeed || speed);
// move all the slides between index and to in the right direction
while (diff--)
move(
circle((to > index ? to : index) - diff - 1),
width * direction,
0
);
if (continuous) move(circle(to - direction), -(width * direction), 0); // we need to get the next in place
} else {
to = circle(to);
animate(index * -width, to * -width, slideSpeed || speed);
//no fallback for a circular continuous if the browser does not accept transitions
}
to = circle(to);
index = to;
offloadFn(options.callback && options.callback(index, slides[index]));
}
move(index, width * direction, slideSpeed || speed);
move(to, 0, slideSpeed || speed);
if (continuous) move(circle(to - direction), -(width * direction), 0); // we need to get the next in place
} else {
to = circle(to);
animate(index * -width, to * -width, slideSpeed || speed);
//no fallback for a circular continuous if the browser does not accept transitions
function move(index, dist, speed) {
translate(index, dist, speed);
slidePos[index] = dist;
}
index = to;
offloadFn(options.callback && options.callback(index, slides[index]));
}
function translate(index, dist, speed) {
var slide = slides[index];
var style = slide && slide.style;
function move(index, dist, speed) {
translate(index, dist, speed);
slidePos[index] = dist;
}
if (!style) return;
function translate(index, dist, speed) {
var slide = slides[index];
var style = slide && slide.style;
style.webkitTransitionDuration = style.MozTransitionDuration = style.msTransitionDuration = style.OTransitionDuration = style.transitionDuration =
speed + 'ms';
if (!style) return;
style.webkitTransform = 'translate(' + dist + 'px,0)' + 'translateZ(0)';
style.msTransform = style.MozTransform = style.OTransform =
'translateX(' + dist + 'px)';
}
style.webkitTransitionDuration = style.MozTransitionDuration = style.msTransitionDuration = style.OTransitionDuration = style.transitionDuration =
speed + 'ms';
function animate(from, to, speed) {
// if not an animation, just reposition
if (!speed) {
element.style.left = to + 'px';
return;
}
style.webkitTransform = 'translate(' + dist + 'px,0)' + 'translateZ(0)';
style.msTransform = style.MozTransform = style.OTransform =
'translateX(' + dist + 'px)';
}
var start = +new Date();
function animate(from, to, speed) {
// if not an animation, just reposition
if (!speed) {
element.style.left = to + 'px';
return;
}
var timer = setInterval(function() {
var timeElap = +new Date() - start;
var start = +new Date();
if (timeElap > speed) {
element.style.left = to + 'px';
var timer = setInterval(function() {
var timeElap = +new Date() - start;
if (delay) begin();
if (timeElap > speed) {
element.style.left = to + 'px';
options.transitionEnd &&
options.transitionEnd.call(event, index, slides[index]);
if (delay) begin();
clearInterval(timer);
return;
}
options.transitionEnd &&
options.transitionEnd.call(event, index, slides[index]);
element.style.left =
(to - from) * (Math.floor((timeElap / speed) * 100) / 100) +
from +
'px';
}, 4);
}
clearInterval(timer);
return;
}
// setup auto slideshow
var delay = options.auto || 0;
var interval;
element.style.left =
(to - from) * (Math.floor((timeElap / speed) * 100) / 100) +
from +
'px';
}, 4);
}
function begin() {
clearTimeout(interval);
interval = setTimeout(next, delay);
}
// setup auto slideshow
var delay = options.auto || 0;
var interval;
function stop() {
delay = 0;
clearTimeout(interval);
}
function begin() {
clearTimeout(interval);
interval = setTimeout(next, delay);
}
// setup initial vars
var start = {};
var delta = {};
var isScrolling;
function stop() {
delay = 0;
clearTimeout(interval);
}
// setup event capturing
var events = {
handleEvent: function(event) {
switch (event.type) {
case 'touchstart':
this.start(event);
break;
case 'touchmove':
this.move(event);
break;
case 'touchend':
offloadFn(this.end(event));
break;
case 'webkitTransitionEnd':
case 'msTransitionEnd':
case 'oTransitionEnd':
case 'otransitionend':
case 'transitionend':
offloadFn(this.transitionEnd(event));
break;
case 'resize':
offloadFn(setup);
break;
}
// setup initial vars
var start = {};
var delta = {};
var isScrolling;
if (options.stopPropagation) event.stopPropagation();
},
start: function(event) {
var touches = event.touches[0];
// setup event capturing
var events = {
handleEvent: function(event) {
switch (event.type) {
case 'touchstart':
this.start(event);
break;
case 'touchmove':
this.move(event);
break;
case 'touchend':
offloadFn(this.end(event));
break;
case 'webkitTransitionEnd':
case 'msTransitionEnd':
case 'oTransitionEnd':
case 'otransitionend':
case 'transitionend':
offloadFn(this.transitionEnd(event));
break;
case 'resize':
offloadFn(setup);
break;
}
// measure start values
start = {
// get initial touch coords
x: touches.pageX,
y: touches.pageY,
if (options.stopPropagation) event.stopPropagation();
},
start: function(event) {
var touches = event.touches[0];
// store time to determine touch duration
time: +new Date()
};
// measure start values
start = {
// get initial touch coords
x: touches.pageX,
y: touches.pageY,
// used for testing first move event
isScrolling = undefined;
// store time to determine touch duration
time: +new Date()
};
// reset delta and end measurements
delta = {};
// used for testing first move event
isScrolling = undefined;
// attach touchmove and touchend listeners
element.addEventListener('touchmove', this, false);
element.addEventListener('touchend', this, false);
},
move: function(event) {
// ensure swiping with one touch and not pinching
if (event.touches.length > 1 || (event.scale && event.scale !== 1))
return;
// reset delta and end measurements
delta = {};
if (options.disableScroll) return;
// attach touchmove and touchend listeners
element.addEventListener('touchmove', this, false);
element.addEventListener('touchend', this, false);
},
move: function(event) {
// ensure swiping with one touch and not pinching
if (event.touches.length > 1 || (event.scale && event.scale !== 1))
return;
var touches = event.touches[0];
if (options.disableScroll) return;
// measure change in x and y
delta = {
x: touches.pageX - start.x,
y: touches.pageY - start.y
};
var touches = event.touches[0];
// determine if scrolling test has run - one time test
if (typeof isScrolling == 'undefined') {
isScrolling = !!(
isScrolling || Math.abs(delta.x) < Math.abs(delta.y)
);
}
// measure change in x and y
delta = {
x: touches.pageX - start.x,
y: touches.pageY - start.y
};
// if user is not trying to scroll vertically
if (!isScrolling) {
// prevent native scrolling
event.preventDefault();
// determine if scrolling test has run - one time test
if (typeof isScrolling == 'undefined') {
isScrolling = !!(isScrolling || Math.abs(delta.x) < Math.abs(delta.y));
}
// stop slideshow
stop();
// if user is not trying to scroll vertically
if (!isScrolling) {
// prevent native scrolling
event.preventDefault();
// increase resistance if first or last slide
if (continuous) {
// we don't add resistance at the end
// stop slideshow
stop();
translate(
circle(index - 1),
delta.x + slidePos[circle(index - 1)],
0
);
translate(index, delta.x + slidePos[index], 0);
translate(
circle(index + 1),
delta.x + slidePos[circle(index + 1)],
0
);
} else {
delta.x =
delta.x /
((!index && delta.x > 0) || // if first slide and sliding left
(index == slides.length - 1 && // or if last slide and sliding right
delta.x < 0) // and if sliding at all
? Math.abs(delta.x) / width + 1 // determine resistance level
: 1); // no resistance if false
// increase resistance if first or last slide
if (continuous) {
// we don't add resistance at the end
// translate 1:1
translate(index - 1, delta.x + slidePos[index - 1], 0);
translate(index, delta.x + slidePos[index], 0);
translate(index + 1, delta.x + slidePos[index + 1], 0);
}
options.swiping && options.swiping(-delta.x / width);
}
},
end: function(event) {
// measure duration
var duration = +new Date() - start.time;
translate(
circle(index - 1),
delta.x + slidePos[circle(index - 1)],
0
);
translate(index, delta.x + slidePos[index], 0);
translate(
circle(index + 1),
delta.x + slidePos[circle(index + 1)],
0
);
} else {
delta.x =
delta.x /
((!index && delta.x > 0) || // if first slide and sliding left
(index == slides.length - 1 && // or if last slide and sliding right
delta.x < 0) // and if sliding at all
? Math.abs(delta.x) / width + 1 // determine resistance level
: 1); // no resistance if false
// determine if slide attempt triggers next/prev slide
var isValidSlide =
(Number(duration) < 250 && // if slide duration is less than 250ms
Math.abs(delta.x) > 20) || // and if slide amt is greater than 20px
Math.abs(delta.x) > width / 2; // or if slide amt is greater than half the width
// translate 1:1
translate(index - 1, delta.x + slidePos[index - 1], 0);
translate(index, delta.x + slidePos[index], 0);
translate(index + 1, delta.x + slidePos[index + 1], 0);
}
options.swiping && options.swiping(-delta.x / width);
}
},
end: function(event) {
// measure duration
var duration = +new Date() - start.time;
// determine if slide attempt is past start and end
var isPastBounds =
(!index && delta.x > 0) || // if first slide and slide amt is greater than 0
(index == slides.length - 1 && delta.x < 0); // or if last slide and slide amt is less than 0
// determine if slide attempt triggers next/prev slide
var isValidSlide =
(Number(duration) < 250 && // if slide duration is less than 250ms
Math.abs(delta.x) > 20) || // and if slide amt is greater than 20px
Math.abs(delta.x) > width / 2; // or if slide amt is greater than half the width
if (continuous) isPastBounds = false;
// determine if slide attempt is past start and end
var isPastBounds =
(!index && delta.x > 0) || // if first slide and slide amt is greater than 0
(index == slides.length - 1 && delta.x < 0); // or if last slide and slide amt is less than 0
// determine direction of swipe (true:right, false:left)
var direction = delta.x < 0;
if (continuous) isPastBounds = false;
// if not scrolling vertically
if (!isScrolling) {
if (isValidSlide && !isPastBounds) {
if (direction) {
if (continuous) {
// we need to get the next in this direction in place
// determine direction of swipe (true:right, false:left)
var direction = delta.x < 0;
move(circle(index - 1), -width, 0);
move(circle(index + 2), width, 0);
} else {
move(index - 1, -width, 0);
}
// if not scrolling vertically
if (!isScrolling) {
if (isValidSlide && !isPastBounds) {
if (direction) {
if (continuous) {
// we need to get the next in this direction in place
move(index, slidePos[index] - width, speed);
move(
circle(index + 1),
slidePos[circle(index + 1)] - width,
speed
);
index = circle(index + 1);
} else {
if (continuous) {
// we need to get the next in this direction in place
move(circle(index - 1), -width, 0);
move(circle(index + 2), width, 0);
} else {
move(index - 1, -width, 0);
move(circle(index + 1), width, 0);
move(circle(index - 2), -width, 0);
} else {
move(index + 1, width, 0);
}
move(index, slidePos[index] + width, speed);
move(
circle(index - 1),
slidePos[circle(index - 1)] + width,
speed
);
index = circle(index - 1);
}
move(index, slidePos[index] - width, speed);
move(circle(index + 1), slidePos[circle(index + 1)] - width, speed);
index = circle(index + 1);
options.callback && options.callback(index, slides[index]);
} else {
if (continuous) {
// we need to get the next in this direction in place
move(circle(index + 1), width, 0);
move(circle(index - 2), -width, 0);
move(circle(index - 1), -width, speed);
move(index, 0, speed);
move(circle(index + 1), width, speed);
} else {
move(index + 1, width, 0);
move(index - 1, -width, speed);
move(index, 0, speed);
move(index + 1, width, speed);
}
move(index, slidePos[index] + width, speed);
move(circle(index - 1), slidePos[circle(index - 1)] + width, speed);
index = circle(index - 1);
}
}
options.callback && options.callback(index, slides[index]);
} else {
if (continuous) {
move(circle(index - 1), -width, speed);
move(index, 0, speed);
move(circle(index + 1), width, speed);
} else {
move(index - 1, -width, speed);
move(index, 0, speed);
move(index + 1, width, speed);
}
// kill touchmove and touchend event listeners until touchstart called again
element.removeEventListener('touchmove', events, false);
element.removeEventListener('touchend', events, false);
element.removeEventListener('touchforcechange', function() {}, false);
},
transitionEnd: function(event) {
if (parseInt(event.target.getAttribute('data-index'), 10) == index) {
if (delay) begin();
options.transitionEnd &&
options.transitionEnd.call(event, index, slides[index]);
}
}
};
// kill touchmove and touchend event listeners until touchstart called again
element.removeEventListener('touchmove', events, false);
element.removeEventListener('touchend', events, false);
element.removeEventListener('touchforcechange', function() {}, false);
},
transitionEnd: function(event) {
if (parseInt(event.target.getAttribute('data-index'), 10) == index) {
if (delay) begin();
// trigger setup
setup();
options.transitionEnd &&
options.transitionEnd.call(event, index, slides[index]);
// start auto slideshow if applicable
if (delay) begin();
// add event listeners
if (browser.addEventListener) {
// set touchstart event on element
if (browser.touch) {
element.addEventListener('touchstart', events, false);
element.addEventListener('touchforcechange', function() {}, false);
}
}
};
// trigger setup
setup();
if (browser.transitions) {
element.addEventListener('webkitTransitionEnd', events, false);
element.addEventListener('msTransitionEnd', events, false);
element.addEventListener('oTransitionEnd', events, false);
element.addEventListener('otransitionend', events, false);
element.addEventListener('transitionend', events, false);
}
// start auto slideshow if applicable
if (delay) begin();
// add event listeners
if (browser.addEventListener) {
// set touchstart event on element
if (browser.touch) {
element.addEventListener('touchstart', events, false);
element.addEventListener('touchforcechange', function() {}, false);
// set resize event on window
window.addEventListener('resize', events, false);
} else {
window.onresize = function() {
setup();
}; // to play nice with old IE
}
if (browser.transitions) {
element.addEventListener('webkitTransitionEnd', events, false);
element.addEventListener('msTransitionEnd', events, false);
element.addEventListener('oTransitionEnd', events, false);
element.addEventListener('otransitionend', events, false);
element.addEventListener('transitionend', events, false);
}
// expose the Swipe API
return {
setup: function() {
setup();
},
slide: function(to, speed) {
// cancel slideshow
stop();
// set resize event on window
window.addEventListener('resize', events, false);
} else {
window.onresize = function() {
setup();
}; // to play nice with old IE
}
slide(to, speed);
},
prev: function() {
// cancel slideshow
stop();
// expose the Swipe API
return {
setup: function() {
setup();
},
slide: function(to, speed) {
// cancel slideshow
stop();
prev();
},
next: function() {
// cancel slideshow
stop();
slide(to, speed);
},
prev: function() {
// cancel slideshow
stop();
next();
},
stop: function() {
// cancel slideshow
stop();
},
getPos: function() {
// return current index position
return index;
},
getNumSlides: function() {
// return total number of slides
return length;
},
kill: function() {
// cancel slideshow
stop();
prev();
},
next: function() {
// cancel slideshow
stop();
// reset element
element.style.width = '';
element.style.left = '';
next();
},
stop: function() {
// cancel slideshow
stop();
},
getPos: function() {
// return current index position
return index;
},
getNumSlides: function() {
// return total number of slides
return length;
},
disableScrolling: function(disableScroll) {
options.disableScroll = disableScroll;
},
kill: function() {
// cancel slideshow
stop();
// reset slides
var pos = slides.length;
while (pos--) {
var slide = slides[pos];
slide.style.width = '';
slide.style.left = '';
// reset element
element.style.width = '';
element.style.left = '';
if (browser.transitions) translate(pos, 0, 0);
}
// reset slides
var pos = slides.length;
while (pos--) {
var slide = slides[pos];
slide.style.width = '';
slide.style.left = '';
if (browser.transitions) translate(pos, 0, 0);
// removed event listeners
if (browser.addEventListener) {
// remove current event listeners
element.removeEventListener('touchstart', events, false);
element.removeEventListener('webkitTransitionEnd', events, false);
element.removeEventListener('msTransitionEnd', events, false);
element.removeEventListener('oTransitionEnd', events, false);
element.removeEventListener('otransitionend', events, false);
element.removeEventListener('transitionend', events, false);
window.removeEventListener('resize', events, false);
} else {
window.onresize = null;
}
}
// removed event listeners
if (browser.addEventListener) {
// remove current event listeners
element.removeEventListener('touchstart', events, false);
element.removeEventListener('webkitTransitionEnd', events, false);
element.removeEventListener('msTransitionEnd', events, false);
element.removeEventListener('oTransitionEnd', events, false);
element.removeEventListener('otransitionend', events, false);
element.removeEventListener('transitionend', events, false);
window.removeEventListener('resize', events, false);
} else {
window.onresize = null;
}
}
};
};
}
module.exports = Swipe;
/***/ })
/******/ });
});
});

@@ -1,1 +0,1 @@

!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.Swipe=n():t.Swipe=n()}(window,function(){return function(e){var i={};function o(t){if(i[t])return i[t].exports;var n=i[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=i,o.d=function(t,n,e){o.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(n,t){if(1&t&&(n=o(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var e=Object.create(null);if(o.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var i in n)o.d(e,i,function(t){return n[t]}.bind(null,i));return e},o.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(n,"a",n),n},o.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},o.p="",o(o.s=0)}([function(t,n){t.exports=function(e,a){var n=function(){},r=function(t){setTimeout(t||n,0)},s={addEventListener:!!window.addEventListener,touch:"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,transitions:function(t){var n=["transitionProperty","WebkitTransition","MozTransition","OTransition","msTransition"];for(var e in n)if(void 0!==t.style[n[e]])return!0;return!1}(document.createElement("swipe"))};if(e){var u,c,d,i,l=e.children[0];a=a||{};var t,f,v=parseInt(a.startSlide,10)||0,h=a.speed||300,p=a.continuous=void 0===a.continuous||a.continuous,m=a.auto||0,b={},x={},E={handleEvent:function(t){switch(t.type){case"touchstart":this.start(t);break;case"touchmove":this.move(t);break;case"touchend":r(this.end(t));break;case"webkitTransitionEnd":case"msTransitionEnd":case"oTransitionEnd":case"otransitionend":case"transitionend":r(this.transitionEnd(t));break;case"resize":r(o)}a.stopPropagation&&t.stopPropagation()},start:function(t){var n=t.touches[0];b={x:n.pageX,y:n.pageY,time:+new Date},f=void 0,x={},l.addEventListener("touchmove",this,!1),l.addEventListener("touchend",this,!1)},move:function(t){if(!(1<t.touches.length||t.scale&&1!==t.scale||a.disableScroll)){var n=t.touches[0];x={x:n.pageX-b.x,y:n.pageY-b.y},void 0===f&&(f=!!(f||Math.abs(x.x)<Math.abs(x.y))),f||(t.preventDefault(),k(),p?(L(y(v-1),x.x+c[y(v-1)],0),L(v,x.x+c[v],0),L(y(v+1),x.x+c[y(v+1)],0)):(x.x=x.x/(!v&&0<x.x||v==u.length-1&&x.x<0?Math.abs(x.x)/d+1:1),L(v-1,x.x+c[v-1],0),L(v,x.x+c[v],0),L(v+1,x.x+c[v+1],0)),a.swiping&&a.swiping(-x.x/d))}},end:function(t){var n=+new Date-b.time,e=Number(n)<250&&20<Math.abs(x.x)||Math.abs(x.x)>d/2,i=!v&&0<x.x||v==u.length-1&&x.x<0;p&&(i=!1);var o=x.x<0;f||(e&&!i?(v=o?(p?(T(y(v-1),-d,0),T(y(v+2),d,0)):T(v-1,-d,0),T(v,c[v]-d,h),T(y(v+1),c[y(v+1)]-d,h),y(v+1)):(p?(T(y(v+1),d,0),T(y(v-2),-d,0)):T(v+1,d,0),T(v,c[v]+d,h),T(y(v-1),c[y(v-1)]+d,h),y(v-1)),a.callback&&a.callback(v,u[v])):p?(T(y(v-1),-d,h),T(v,0,h),T(y(v+1),d,h)):(T(v-1,-d,h),T(v,0,h),T(v+1,d,h))),l.removeEventListener("touchmove",E,!1),l.removeEventListener("touchend",E,!1),l.removeEventListener("touchforcechange",function(){},!1)},transitionEnd:function(t){parseInt(t.target.getAttribute("data-index"),10)==v&&(m&&M(),a.transitionEnd&&a.transitionEnd.call(t,v,u[v]))}};return o(),m&&M(),s.addEventListener?(s.touch&&(l.addEventListener("touchstart",E,!1),l.addEventListener("touchforcechange",function(){},!1)),s.transitions&&(l.addEventListener("webkitTransitionEnd",E,!1),l.addEventListener("msTransitionEnd",E,!1),l.addEventListener("oTransitionEnd",E,!1),l.addEventListener("otransitionend",E,!1),l.addEventListener("transitionend",E,!1)),window.addEventListener("resize",E,!1)):window.onresize=function(){o()},{setup:function(){o()},slide:function(t,n){k(),g(t,n)},prev:function(){k(),p?g(v-1):v&&g(v-1)},next:function(){k(),w()},stop:function(){k()},getPos:function(){return v},getNumSlides:function(){return i},disableScrolling:function(t){a.disableScroll=t},kill:function(){k(),l.style.width="",l.style.left="";for(var t=u.length;t--;){var n=u[t];n.style.width="",n.style.left="",s.transitions&&L(t,0,0)}s.addEventListener?(l.removeEventListener("touchstart",E,!1),l.removeEventListener("webkitTransitionEnd",E,!1),l.removeEventListener("msTransitionEnd",E,!1),l.removeEventListener("oTransitionEnd",E,!1),l.removeEventListener("otransitionend",E,!1),l.removeEventListener("transitionend",E,!1),window.removeEventListener("resize",E,!1)):window.onresize=null}}}function o(){u=l.children,i=u.length,p=!(u.length<2)&&a.continuous,c=new Array(u.length),d=Math.round(e.getBoundingClientRect().width||e.offsetWidth),l.style.width=u.length*d+"px";for(var t=u.length;t--;){var n=u[t];n.style.width=d+"px",n.setAttribute("data-index",t),s.transitions&&(n.style.left=t*-d+"px",T(t,t<v?-d:v<t?d:0,0))}p&&s.transitions&&(T(y(v-1),-d,0),T(y(v+1),d,0)),s.transitions||(l.style.left=v*-d+"px"),e.style.visibility="visible"}function w(){p?g(v+1):v<u.length-1&&g(v+1)}function y(t){return(u.length+t%u.length)%u.length}function g(t,n){if(v!=t){if(s.transitions){var e=Math.abs(v-t)/(v-t);if(p){var i=e;(e=-c[y(t)]/d)!==i&&(t=-e*u.length+t)}for(var o=Math.abs(v-t)-1;o--;)T(y((v<t?t:v)-o-1),d*e,0);t=y(t),T(v,d*e,n||h),T(t,0,n||h),p&&T(y(t-e),-d*e,0)}else t=y(t),function(n,e,i){if(!i)return l.style.left=e+"px";var o=+new Date,r=setInterval(function(){var t=+new Date-o;if(i<t)return l.style.left=e+"px",m&&M(),a.transitionEnd&&a.transitionEnd.call(event,v,u[v]),void clearInterval(r);l.style.left=(e-n)*(Math.floor(t/i*100)/100)+n+"px"},4)}(v*-d,t*-d,n||h);v=t,r(a.callback&&a.callback(v,u[v]))}}function T(t,n,e){L(t,n,e),c[t]=n}function L(t,n,e){var i=u[t],o=i&&i.style;o&&(o.webkitTransitionDuration=o.MozTransitionDuration=o.msTransitionDuration=o.OTransitionDuration=o.transitionDuration=e+"ms",o.webkitTransform="translate("+n+"px,0)translateZ(0)",o.msTransform=o.MozTransform=o.OTransform="translateX("+n+"px)")}function M(){clearTimeout(t),t=setTimeout(w,m)}function k(){m=0,clearTimeout(t)}}}])});
(function(e,t){if(typeof module!=="undefined"&&module.exports){module.exports=t()}else{e.Swipe=t()}})(this,function(){"use strict";return function Swipe(n,r){var t=function(){};var s=function(e){setTimeout(e||t,0)};var o={addEventListener:!!window.addEventListener,touch:"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,transitions:function(e){var t=["transitionProperty","WebkitTransition","MozTransition","OTransition","msTransition"];for(var n in t)if(e.style[t[n]]!==undefined)return true;return false}(document.createElement("swipe"))};if(!n)return;var f=n.children[0];var l,u,d,i;r=r||{};var c=parseInt(r.startSlide,10)||0;var v=r.speed||300;var h=r.continuous=r.continuous!==undefined?r.continuous:true;function a(){l=f.children;i=l.length;h=l.length<2?false:r.continuous;u=new Array(l.length);d=Math.round(n.getBoundingClientRect().width||n.offsetWidth);f.style.width=l.length*d+"px";var e=l.length;while(e--){var t=l[e];t.style.width=d+"px";t.setAttribute("data-index",e);if(o.transitions){t.style.left=e*-d+"px";x(e,c>e?-d:c<e?d:0,0)}}if(h&&o.transitions){x(E(c-1),-d,0);x(E(c+1),d,0)}if(!o.transitions)f.style.left=c*-d+"px";n.style.visibility="visible"}function e(){if(h)w(c-1);else if(c)w(c-1)}function m(){if(h)w(c+1);else if(c<l.length-1)w(c+1)}function E(e){return(l.length+e%l.length)%l.length}function w(e,t){if(c==e)return;if(o.transitions){var n=Math.abs(c-e)/(c-e);if(h){var i=n;n=-u[E(e)]/d;if(n!==i)e=-n*l.length+e}var a=Math.abs(c-e)-1;while(a--)x(E((e>c?e:c)-a-1),d*n,0);e=E(e);x(c,d*n,t||v);x(e,0,t||v);if(h)x(E(e-n),-(d*n),0)}else{e=E(e);g(c*-d,e*-d,t||v)}c=e;s(r.callback&&r.callback(c,l[c]))}function x(e,t,n){p(e,t,n);u[e]=t}function p(e,t,n){var i=l[e];var a=i&&i.style;if(!a)return;a.webkitTransitionDuration=a.MozTransitionDuration=a.msTransitionDuration=a.OTransitionDuration=a.transitionDuration=n+"ms";a.webkitTransform="translate("+t+"px,0)"+"translateZ(0)";a.msTransform=a.MozTransform=a.OTransform="translateX("+t+"px)"}function g(t,n,i){if(!i){f.style.left=n+"px";return}var a=+new Date;var s=setInterval(function(){var e=+new Date-a;if(e>i){f.style.left=n+"px";if(b)y();r.transitionEnd&&r.transitionEnd.call(event,c,l[c]);clearInterval(s);return}f.style.left=(n-t)*(Math.floor(e/i*100)/100)+t+"px"},4)}var b=r.auto||0;var T;function y(){clearTimeout(T);T=setTimeout(m,b)}function L(){b=0;clearTimeout(T)}var k={};var D={};var M;var z={handleEvent:function(e){switch(e.type){case"touchstart":this.start(e);break;case"touchmove":this.move(e);break;case"touchend":s(this.end(e));break;case"webkitTransitionEnd":case"msTransitionEnd":case"oTransitionEnd":case"otransitionend":case"transitionend":s(this.transitionEnd(e));break;case"resize":s(a);break}if(r.stopPropagation)e.stopPropagation()},start:function(e){var t=e.touches[0];k={x:t.pageX,y:t.pageY,time:+new Date};M=undefined;D={};f.addEventListener("touchmove",this,false);f.addEventListener("touchend",this,false)},move:function(e){if(e.touches.length>1||e.scale&&e.scale!==1)return;if(r.disableScroll)return;var t=e.touches[0];D={x:t.pageX-k.x,y:t.pageY-k.y};if(typeof M=="undefined"){M=!!(M||Math.abs(D.x)<Math.abs(D.y))}if(!M){e.preventDefault();L();if(h){p(E(c-1),D.x+u[E(c-1)],0);p(c,D.x+u[c],0);p(E(c+1),D.x+u[E(c+1)],0)}else{D.x=D.x/(!c&&D.x>0||c==l.length-1&&D.x<0?Math.abs(D.x)/d+1:1);p(c-1,D.x+u[c-1],0);p(c,D.x+u[c],0);p(c+1,D.x+u[c+1],0)}r.swiping&&r.swiping(-D.x/d)}},end:function(e){var t=+new Date-k.time;var n=Number(t)<250&&Math.abs(D.x)>20||Math.abs(D.x)>d/2;var i=!c&&D.x>0||c==l.length-1&&D.x<0;if(h)i=false;var a=D.x<0;if(!M){if(n&&!i){if(a){if(h){x(E(c-1),-d,0);x(E(c+2),d,0)}else{x(c-1,-d,0)}x(c,u[c]-d,v);x(E(c+1),u[E(c+1)]-d,v);c=E(c+1)}else{if(h){x(E(c+1),d,0);x(E(c-2),-d,0)}else{x(c+1,d,0)}x(c,u[c]+d,v);x(E(c-1),u[E(c-1)]+d,v);c=E(c-1)}r.callback&&r.callback(c,l[c])}else{if(h){x(E(c-1),-d,v);x(c,0,v);x(E(c+1),d,v)}else{x(c-1,-d,v);x(c,0,v);x(c+1,d,v)}}}f.removeEventListener("touchmove",z,false);f.removeEventListener("touchend",z,false);f.removeEventListener("touchforcechange",function(){},false)},transitionEnd:function(e){if(parseInt(e.target.getAttribute("data-index"),10)==c){if(b)y();r.transitionEnd&&r.transitionEnd.call(e,c,l[c])}}};a();if(b)y();if(o.addEventListener){if(o.touch){f.addEventListener("touchstart",z,false);f.addEventListener("touchforcechange",function(){},false)}if(o.transitions){f.addEventListener("webkitTransitionEnd",z,false);f.addEventListener("msTransitionEnd",z,false);f.addEventListener("oTransitionEnd",z,false);f.addEventListener("otransitionend",z,false);f.addEventListener("transitionend",z,false)}window.addEventListener("resize",z,false)}else{window.onresize=function(){a()}}return{setup:function(){a()},slide:function(e,t){L();w(e,t)},prev:function(){L();e()},next:function(){L();m()},stop:function(){L()},getPos:function(){return c},getNumSlides:function(){return i},kill:function(){L();f.style.width="";f.style.left="";var e=l.length;while(e--){var t=l[e];t.style.width="";t.style.left="";if(o.transitions)p(e,0,0)}if(o.addEventListener){f.removeEventListener("touchstart",z,false);f.removeEventListener("webkitTransitionEnd",z,false);f.removeEventListener("msTransitionEnd",z,false);f.removeEventListener("oTransitionEnd",z,false);f.removeEventListener("otransitionend",z,false);f.removeEventListener("transitionend",z,false);window.removeEventListener("resize",z,false)}else{window.onresize=null}}}}});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc