New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fex-swiper

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fex-swiper - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

1042

dist/swiper.js

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

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var i=e();for(var n in i)("object"==typeof exports?exports:t)[n]=i[n]}}(this,function(){return function(t){function e(n){if(i[n])return i[n].exports;var s=i[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,e),s.l=!0,s.exports}var i={};return e.m=t,e.c=i,e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=2)}([function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.EMPTY_FUNCTION=function(){},e.EMPTY_PAGE=document.createElement("div"),e.OPPSITE={X:"Y",Y:"X"}},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.register=function(e,i){t._renders[e]=i},t.getRenderInstance=function(e){var i=t._renders[e];if(!i)throw new Error("Missing render : "+e);return new i},t.prototype.sign=function(t){return t=+t,0===t||isNaN(t)?0:t>0?1:-1},t}();n._renders={},e.default=n},function(t,e,i){"use strict";var n=this&&this.__assign||Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t};Object.defineProperty(e,"__esModule",{value:!0}),i(3);var s=i(4),r=i(0),a=i(5),o=i(6),c=i(1),h=i(7),u=i(8),d=i(9),f=i(10),p=i(11),l=i(12);c.default.register("slide",h.default),c.default.register("rotate",u.default),c.default.register("flip",d.default),c.default.register("card",f.default),c.default.register("fade",p.default),c.default.register("dumi",l.default);var v=function(){function t(e){e=n({},t.DefaultOptions,e),e.transition=n({},t.DefaultOptions.transition,e.transition),this.$container=e.container,this.debug=e.debug,this.data=e.data,this.axis=e.isVertical?"Y":"X",this.isLoop=e.isLoop,this.initIndex=e.initIndex,this.keepDefaultClasses=e.keepDefaultClasses,this.sideLength="X"===this.axis?this.$container.clientWidth:this.$container.clientHeight,this.transition=e.transition,this._listeners={},this.sliding=!1,this.moving=!1,this.pageChange=!1,this.moveDirection=a.Direction.Nonward,this.activePage=r.EMPTY_PAGE,this.lastActivePage=r.EMPTY_PAGE,this.start={X:0,Y:0},this.end={X:0,Y:0},this.offset={X:0,Y:0},this.log=this.debug?console.log.bind(window.console):r.EMPTY_FUNCTION,this.bindEvents(),this.initRender()}return t.prototype.bindEvents=function(){this.$container.addEventListener(t.Device.startEvent,this,{passive:!1}),this.$container.addEventListener(t.Device.moveEvent,this,{passive:!1}),this.$container.addEventListener(t.Device.transitionEvent,this,{passive:!1}),window.addEventListener(t.Device.endEvent,this,{passive:!1}),window.addEventListener(t.Device.resizeEvent,this,!1)},t.prototype.unbindEvents=function(){this.$container.removeEventListener(t.Device.startEvent,this,{passive:!1}),this.$container.removeEventListener(t.Device.moveEvent,this,{passive:!1}),this.$container.removeEventListener(t.Device.transitionEvent,this,{passive:!1}),window.removeEventListener(t.Device.endEvent,this,{passive:!1}),window.removeEventListener(t.Device.resizeEvent,this,!1)},t.prototype.handleEvent=function(e){var i=t.Device.getDeviceEvent(e);switch(i.type){case"mousedown":if(0!==i.button)break;case"touchstart":this.keepDefaultHandler(i),this.startHandler(i.position);break;case t.Device.moveEvent:this.keepDefaultHandler(i),this.moveHandler(i.position);break;case t.Device.endEvent:case t.Device.cancelEvent:this.endHandler();break;case t.Device.resizeEvent:this.resizeHandler();break;case t.Device.transitionEvent:this.transitionEndHandler(i)}},t.prototype.keepDefaultHandler=function(t){if(!t.target||!/^(input|textarea|a|select)$/i.test(t.target.tagName)){for(var e=this.keepDefaultClasses,i=0,n=e;i<n.length;i++){var s=n[i];if(t.target.classList.contains(s))return}t.preventDefault()}},t.prototype.startHandler=function(t){this.sliding||(this.log("start"),this.moving=!0,this.startTime=(new Date).getTime(),this.start=t,this.transition=n({},this.transition,this.currentPage.transition),this.renderInstance=c.default.getRenderInstance(this.transition.name),this.transition.direction!==a.Direction.Nonward&&this.fire("swipeStart"))},t.prototype.moveHandler=function(t){if(!this.sliding&&this.moving&&this.transition.direction!==a.Direction.Nonward){this.log("moving"),this.end=t,this.offset={X:this.end.X-this.start.X,Y:this.end.Y-this.start.Y},this.offset[this.axis]<0?(this.moveDirection=a.Direction.Forward,this.lastActivePage=this.activePage,this.activePage=this.currentPage.next):this.offset[this.axis]>0?(this.moveDirection=a.Direction.Backward,this.lastActivePage=this.activePage,this.activePage=this.currentPage.prev):(this.moveDirection=a.Direction.Nonward,this.lastActivePage=this.activePage,this.activePage=r.EMPTY_PAGE),this.fire("swipeMoving"),this.activePage!==this.lastActivePage&&this.activePage!==r.EMPTY_PAGE&&this.fire("activePageChanged"),this.transition.direction&&this.transition.direction!==this.moveDirection&&(this.offset[this.axis]=0,this.start=this.end);var e={Forward:20,Backward:this.sideLength-20},i=a.Direction[this.moveDirection];if(this.moveDirection*this.end[this.axis]>this.moveDirection*e[i]){var n=this.moveDirection===a.Direction.Forward?"<--- near edge":"near edge ---\x3e";return this.log(n),this.endHandler()}0!==this.transition.duration&&this.render()}},t.prototype.endHandler=function(){if(!this.sliding&&this.moving&&this.transition.direction!==a.Direction.Nonward){this.moving=!1,this.log("end"),this.transition.direction&&this.transition.direction!==this.moveDirection&&(this.offset[this.axis]=0),this.endTime=(new Date).getTime();var t=this.endTime-this.startTime,e=t>300?this.sideLength/3:14,i=(this.offset[this.axis],Math.abs(this.offset[this.axis])),n=Math.abs(this.offset[r.OPPSITE[this.axis]]),s=n<i;i>=e&&s&&this.activePage!==r.EMPTY_PAGE?(this.pageChange=!0,this._swipeTo()):(this.pageChange=!1,this._swipeTo(),this.fire("swipeRestore"))}},t.prototype.resizeHandler=function(){this.sliding||this.moving||(this.sideLength="X"===this.axis?this.$container.clientWidth:this.$container.clientHeight)},t.prototype.transitionEndHandler=function(t){t&&t.target!==this.currentPage||(this.$swiper.style.cssText="",this.currentPage.style.cssText="",this.activePage.style.cssText="",!1===this.pageChange?(this.activePage.classList.remove("active"),this.fire("swipeRestored")):(this.currentPage.classList.remove("current"),this.activePage.classList.remove("active"),this.activePage.classList.add("current"),this.currentPage=this.activePage,this.fire("swipeChanged")),this.activePage=r.EMPTY_PAGE,this.lastActivePage=r.EMPTY_PAGE,this.offset.X=0,this.offset.Y=0,this.sliding=!1,this.pageChange=!1)},t.prototype.swipeTo=function(t,e){if(!this.sliding){var i=this.currentPage.index;this.moveDirection=a.Direction.Nonward,this.pageChange=!0,t>i?this.moveDirection=a.Direction.Forward:t<i&&(this.moveDirection=a.Direction.Backward);var s=this.isLoop?(t+this.data.length)%this.data.length:t;this.activePage=this.$pages[s]||r.EMPTY_PAGE,s!==i&&this.activePage!==r.EMPTY_PAGE||(this.pageChange=!1),this.transition=n({},this.transition,this.currentPage.transition,e),this.renderInstance=c.default.getRenderInstance(this.transition.name),this.fire("activePageChanged"),this.render(),this._swipeTo()}},t.prototype.swipePrev=function(t){var e=this.currentPage.index;this.swipeTo(e-1,t)},t.prototype.swipeNext=function(t){var e=this.currentPage.index;this.swipeTo(e+1,t)},t.prototype.getCurrentIndex=function(){return this.currentPage.index},t.prototype._swipeTo=function(){if(!this.sliding){this.sliding=!0;var t=this.activePage===r.EMPTY_PAGE?300:this.transition.duration,e=Math.abs(this.offset[this.axis])/this.sideLength*t,i=t-e,n=this.pageChange?i:e,s=this.pageChange?this.moveDirection*this.sideLength:0;if(0===n)return this.transitionEndHandler();setTimeout(function(){this.currentPage.style.webkitTransition="ease-out "+n+"ms",this.activePage!==r.EMPTY_PAGE&&(this.activePage.style.webkitTransition="ease-out "+n+"ms"),this.offset[this.axis]=s,this.render()}.bind(this),30)}},t.prototype.initRender=function(){var t=this;this.$swiper=document.createElement("div"),this.$swiper.classList.add("lg-swiper"),this.$pages=this.data.map(function(e,i){var n=document.createElement("div");return n.classList.add("lg-swiper-page"),"string"==typeof e.content?n.innerHTML=e.content:n.appendChild(e.content),n.index=i,n.transition=e.transition,t.initIndex===i&&(n.classList.add("current"),t.currentPage=n),t.$swiper.appendChild(n),n}),this.$pages.forEach(function(e,i,n){var s=t.isLoop?(n.length+i-1)%n.length:i-1,a=t.isLoop?(n.length+i+1)%n.length:i+1;e.prev=t.$pages[s]||r.EMPTY_PAGE,e.next=t.$pages[a]||r.EMPTY_PAGE}),this.$container.style.overflow="hidden",this.$container.appendChild(this.$swiper)},t.prototype.on=function(t,e){for(var i=t.split(" "),n=0,s=i;n<s.length;n++){var r=s[n];this._listeners[r]||(this._listeners[r]=[]),this._listeners[r].push(e)}return this},t.prototype.off=function(t,e){if(this._listeners[t]){var i=this._listeners[t].indexOf(e);i>-1&&this._listeners[t].splice(i,1)}return this},t.prototype.fire=function(t,e){if(void 0===e&&(e={}),this._listeners[t])for(var i=0,s=this._listeners[t];i<s.length;i++){var r=s[i],a=n({},e,{name:t});r.call(this,a)}return this},t.prototype.destroy=function(){this.unbindEvents(),this._listeners={},this.$container.style.overflow="",this.$swiper.parentElement.removeChild(this.$swiper),this.fire("destroy")},t.prototype.render=function(){this.lastActivePage!==this.activePage&&(this.lastActivePage.classList.remove("active"),this.lastActivePage.style.cssText="",this.activePage!==r.EMPTY_PAGE&&this.activePage.classList.add("active")),this.log("offset : "+this.offset[this.axis]);var t=o.default.easeOutQuad;this.activePage===r.EMPTY_PAGE&&(t=o.default.rubberBand),this.renderInstance.doRender({axis:this.axis,moveDirection:this.moveDirection,sideOffset:t(this.offset[this.axis],this.sideLength),sideLength:this.sideLength,$swiper:this.$swiper,currentPage:this.currentPage,activePage:this.activePage})},t}();v.Events=["swipeBeforeStart","swipeStart","swipeMoving","swipeChanged","swipeRestore","swipeRestored","activePageChanged","destroy"],v.Device=new s.Device(window),v.DefaultOptions={container:document.body,data:[],debug:!1,isVertical:!0,isLoop:!1,initIndex:0,keepDefaultClasses:[],transition:{name:"slide",duration:800}},e.Swiper=v},function(t,e){},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(t){this.hasTouch=!!("ontouchstart"in t||t.DocumentTouch&&t.document instanceof t.DocumentTouch),this.startEvent=this.hasTouch?"touchstart":"mousedown",this.moveEvent=this.hasTouch?"touchmove":"mousemove",this.endEvent=this.hasTouch?"touchend":"mouseup",this.cancelEvent=this.hasTouch?"touchcancel":"mouseout",this.transitionEvent=this.getTransitionEvent(),this.resizeEvent="resize"}return t.prototype.getDeviceEvent=function(t){var e=this.hasTouch?this.getTouchPosition(t):this.getMousePosition(t);return{type:t.type,position:e,target:t.target,button:t.button,preventDefault:t.preventDefault.bind(t)}},t.prototype.getTouchPosition=function(t){return t.targetTouches&&t.targetTouches.length>0?{X:t.targetTouches[0].pageX,Y:t.targetTouches[0].pageY}:{X:void 0,Y:void 0}},t.prototype.getMousePosition=function(t){return"pageX"in t?{X:t.pageX,Y:t.pageY}:{X:void 0,Y:void 0}},t.prototype.getTransitionEvent=function(){var t=document.createElement("fakeelement"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(var i in e)if(void 0!==t.style[i])return e[i]},t}();e.Device=n},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});!function(t){t[t.Forward=-1]="Forward",t[t.Nonward=0]="Nonward",t[t.Backward=1]="Backward"}(e.Direction||(e.Direction={}))},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=function(){function t(){}return t.easeOutQuad=function(e,i){var n=Math.abs(e/i),s=.5*n*(3-n);return t.sign(e)*s*i},t.rubberBand=function(e,i){var n=Math.abs(e/i),s=1-1/(.55*n+1);return t.sign(e)*s*i},t.sign=function(t){return t=+t,0===t||isNaN(t)?0:t>0?1:-1},t}();e.default=n},function(t,e,i){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var s=i(1),r=i(0),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.doRender=function(t){var e=t.axis,i=t.sideOffset,n=t.sideLength,s=t.moveDirection,a="translateZ(0) translate"+e+"("+i+"px)",o="translateZ(0) translate"+e+"("+(i-s*n)+"px)";t.currentPage.style.webkitTransform=a,t.activePage!==r.EMPTY_PAGE&&(t.activePage.style.webkitTransform=o)},e}(s.default);e.default=a},function(t,e,i){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var s=i(1),r=i(0),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.doRender=function(t){var e=t.axis,i=t.sideOffset,n=t.sideLength,s=r.OPPSITE[e],a=t.moveDirection,o="Y"===e?-1:1,c="-webkit-perspective:"+4*n+"px;-webkit-transform-style:preserve-3d;",h="rotate"+s+"("+90*o*i/n+"deg) translateZ("+.889*n/2+"px) scale(0.889)",u="rotate"+s+"("+90*o*(i/n-a)+"deg) translateZ("+.889*n/2+"px) scale(0.889)";t.$swiper.style.cssText=c,t.currentPage.style.webkitTransform=h,t.activePage!==r.EMPTY_PAGE&&(t.activePage.style.webkitTransform=u)},e}(s.default);e.default=a},function(t,e,i){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var s=i(1),r=i(0),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.doRender=function(t){var e=t.axis,i=t.sideOffset,n=t.sideLength,s=r.OPPSITE[e],a="Y"===e?-1:1,o="-webkit-perspective:"+4*n+"px;-webkit-transform-style:flat;",c="translateZ("+n/2+"px) rotate"+s+"("+180*a*i/n+"deg) scale(0.875)",h="translateZ("+n/2+"px) rotate"+s+"("+180*a*(i/n+1)+"deg) scale(0.875)";t.$swiper.style.cssText=o,t.currentPage.style.webkitBackfaceVisibility="hidden",t.currentPage.style.webkitTransform=c,t.activePage!==r.EMPTY_PAGE&&(t.activePage.style.webkitBackfaceVisibility="hidden",t.activePage.style.webkitTransform=h,t.activePage.style.zIndex=7)},e}(s.default);e.default=a},function(t,e,i){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var s=i(1),r=i(0),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.doRender=function(t){var e=t.axis,i=t.sideOffset,n=t.sideLength,s=r.OPPSITE[e],a=1-.2*Math.abs(i/n),o=t.moveDirection,c="translateZ(0) scale"+s+"("+a+") translate"+e+"("+i+"px)",h="translateZ(0) translate"+e+"("+(i-o*n)+"px)";t.currentPage.style.webkitTransform=c,t.activePage!==r.EMPTY_PAGE&&(t.activePage.style.webkitTransform=h)},e}(s.default);e.default=a},function(t,e,i){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var s=i(1),r=i(0),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.doRender=function(t){var e=(t.axis,t.sideOffset),i=t.sideLength;t.currentPage.style.opacity=1-Math.abs(e/i),t.activePage!==r.EMPTY_PAGE&&(t.activePage.style.opacity=Math.abs(e/i))},e}(s.default);e.default=a},function(t,e,i){"use strict";var n=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();Object.defineProperty(e,"__esModule",{value:!0});var s=i(1),r=i(0),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.doRender=function(t){var e=t.axis,i=t.sideOffset,n=t.sideLength,s=(r.OPPSITE[e],1-.4*Math.min(Math.abs(i/n),.5)),a=.8+.4*Math.min(Math.abs(i/n),.5),o=t.moveDirection,c="translateZ(0) translate"+e+"("+i+"px) scale("+s+")",h="translateZ(0) translate"+e+"("+(i-o*n)+"px) scale("+a+")";t.currentPage.style.webkitTransform=c,t.activePage!==r.EMPTY_PAGE&&(t.activePage.style.webkitTransform=h)},e}(s.default);e.default=a}])});
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else {
var a = factory();
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
})(this, 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, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // 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 = 2);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
*
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.EMPTY_FUNCTION = function () { };
exports.EMPTY_PAGE = document.createElement('div');
exports.OPPSITE = {
X: 'Y',
Y: 'X'
};
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @file render.ts 抽象类,为渲染提供运行时支持
*
* @author: zhangbobell
* @email: zhangbobell@163.com
*
* @created: 2017.06.27
*/
Object.defineProperty(exports, "__esModule", { value: true });
var Render = (function () {
function Render() {
}
Render.register = function (name, renderClass) {
Render._renders[name] = renderClass;
};
Render.getRenderInstance = function (name) {
var RenderClass = Render._renders[name];
if (!RenderClass) {
throw new Error("Missing render : " + name);
}
return new RenderClass();
};
Render.prototype.sign = function (x) {
x = +x;
if (x === 0 || isNaN(x)) {
return 0;
}
return x > 0 ? 1 : -1;
};
return Render;
}());
Render._renders = {};
exports.default = Render;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @file swiper.ts swiper 主文件
*
* @author: zhangbobell
* @email: zhangbobell@163.com
* @created: 2017.06.26
*
*/
__webpack_require__(3);
var device_1 = __webpack_require__(4);
var constant_1 = __webpack_require__(0);
var interface_1 = __webpack_require__(5);
var easing_1 = __webpack_require__(6);
var render_1 = __webpack_require__(1);
var slide_1 = __webpack_require__(7);
var rotate_1 = __webpack_require__(8);
var flip_1 = __webpack_require__(9);
var card_1 = __webpack_require__(10);
var fade_1 = __webpack_require__(11);
var dumi_1 = __webpack_require__(12);
render_1.default.register('slide', slide_1.default);
render_1.default.register('rotate', rotate_1.default);
render_1.default.register('flip', flip_1.default);
render_1.default.register('card', card_1.default);
render_1.default.register('fade', fade_1.default);
render_1.default.register('dumi', dumi_1.default);
var Swiper = (function () {
function Swiper(options) {
options = __assign({}, Swiper.DefaultOptions, options);
options.transition = __assign({}, Swiper.DefaultOptions.transition, options.transition);
this.$container = options.container;
this.debug = options.debug;
this.data = options.data;
this.axis = options.isVertical ? 'Y' : 'X';
this.isLoop = options.isLoop;
this.initIndex = options.initIndex;
this.keepDefaultClasses = options.keepDefaultClasses;
this.sideLength = this.axis === 'X' ? this.$container.clientWidth : this.$container.clientHeight;
this.transition = options.transition;
this._listeners = {};
// runtime variable
this.sliding = false;
this.moving = false;
this.pageChange = false;
this.moveDirection = interface_1.Direction.Nonward;
this.activePage = constant_1.EMPTY_PAGE;
this.lastActivePage = constant_1.EMPTY_PAGE;
this.start = { X: 0, Y: 0 };
this.end = { X: 0, Y: 0 };
this.offset = { X: 0, Y: 0 };
this.log = this.debug ? console.log.bind(window.console) : constant_1.EMPTY_FUNCTION;
this.bindEvents();
this.initRender();
}
Swiper.prototype.bindEvents = function () {
this.$container.addEventListener(Swiper.Device.startEvent, this, { passive: false });
this.$container.addEventListener(Swiper.Device.moveEvent, this, { passive: false });
this.$container.addEventListener(Swiper.Device.transitionEvent, this, { passive: false });
window.addEventListener(Swiper.Device.endEvent, this, { passive: false });
window.addEventListener(Swiper.Device.resizeEvent, this, false);
};
Swiper.prototype.unbindEvents = function () {
this.$container.removeEventListener(Swiper.Device.startEvent, this, { passive: false });
this.$container.removeEventListener(Swiper.Device.moveEvent, this, { passive: false });
this.$container.removeEventListener(Swiper.Device.transitionEvent, this, { passive: false });
window.removeEventListener(Swiper.Device.endEvent, this, { passive: false });
window.removeEventListener(Swiper.Device.resizeEvent, this, false);
};
Swiper.prototype.handleEvent = function (event) {
var deviceEvent = Swiper.Device.getDeviceEvent(event);
switch (deviceEvent.type) {
case 'mousedown':
// block mouse buttons except left
if (deviceEvent.button !== 0) {
break;
}
case 'touchstart':
this.keepDefaultHandler(deviceEvent);
this.startHandler(deviceEvent.position);
break;
case Swiper.Device.moveEvent:
this.keepDefaultHandler(deviceEvent);
this.moveHandler(deviceEvent.position);
break;
case Swiper.Device.endEvent:
case Swiper.Device.cancelEvent:
// mouseout, touchcancel event, trigger endEvent
this.endHandler();
break;
case Swiper.Device.resizeEvent:
this.resizeHandler();
break;
case Swiper.Device.transitionEvent:
this.transitionEndHandler(deviceEvent);
break;
default:
break;
}
};
Swiper.prototype.keepDefaultHandler = function (event) {
if (event.target && /^(input|textarea|a|select)$/i.test(event.target.tagName)) {
return;
}
var keepDefaultClasses = this.keepDefaultClasses;
for (var _i = 0, keepDefaultClasses_1 = keepDefaultClasses; _i < keepDefaultClasses_1.length; _i++) {
var keepDefaultClass = keepDefaultClasses_1[_i];
for (var e = event.target; e !== null; e = e.parentElement) {
if (e.classList.contains(keepDefaultClass)) {
console.log('catch keep default : ', e.classList);
return;
}
}
}
console.log('prevent default le..');
event.preventDefault();
};
Swiper.prototype.startHandler = function (startPosition) {
if (this.sliding) {
return;
}
this.log('start');
this.moving = true;
this.startTime = new Date().getTime();
this.start = startPosition;
// 设置翻页动画
this.transition = __assign({}, this.transition, this.currentPage.transition);
this.renderInstance = render_1.default.getRenderInstance(this.transition.name);
if (this.transition.direction === interface_1.Direction.Nonward) {
return;
}
this.fire('swipeStart');
};
Swiper.prototype.moveHandler = function (movingPosition) {
if (this.sliding || !this.moving || this.transition.direction === interface_1.Direction.Nonward) {
return;
}
this.log('moving');
this.end = movingPosition;
this.offset = {
X: this.end.X - this.start.X,
Y: this.end.Y - this.start.Y
};
if (this.offset[this.axis] < 0) {
this.moveDirection = interface_1.Direction.Forward;
this.lastActivePage = this.activePage;
this.activePage = this.currentPage.next;
}
else if (this.offset[this.axis] > 0) {
this.moveDirection = interface_1.Direction.Backward;
this.lastActivePage = this.activePage;
this.activePage = this.currentPage.prev;
}
else {
this.moveDirection = interface_1.Direction.Nonward;
this.lastActivePage = this.activePage;
this.activePage = constant_1.EMPTY_PAGE;
}
this.fire('swipeMoving');
if (this.activePage !== this.lastActivePage && this.activePage !== constant_1.EMPTY_PAGE) {
this.fire('activePageChanged');
}
// 页面禁止滑动时
// 防止突然「先上后下」,直接将 this.offset 置为 0
// 防止需要「等」 offset 归 0 后才能往上走
if (this.transition.direction && this.transition.direction !== this.moveDirection) {
this.offset[this.axis] = 0;
this.start = this.end;
}
var GAP = {
Forward: 20,
Backward: this.sideLength - 20
};
var directionKey = interface_1.Direction[this.moveDirection];
if (this.moveDirection * this.end[this.axis] > this.moveDirection * GAP[directionKey]) {
var logStr = this.moveDirection === interface_1.Direction.Forward ? '<--- near edge' : 'near edge --->';
this.log(logStr);
return this.endHandler();
}
// activePage 为 EMPTY_PAGE 需要渲染,比如快速滑动最后一帧
// 翻页时长为 0 时不渲染,但是需要在上面判断是否在边界附近
if (this.transition.duration !== 0) {
this.render();
}
};
Swiper.prototype.endHandler = function () {
if (this.sliding || !this.moving || this.transition.direction === interface_1.Direction.Nonward) {
return;
}
this.moving = false;
this.log('end');
// 如果禁止滑动
if (this.transition.direction && this.transition.direction !== this.moveDirection) {
this.offset[this.axis] = 0;
}
this.endTime = new Date().getTime();
var moveTime = this.endTime - this.startTime;
var threshold = moveTime > 300 ? this.sideLength / 3 : 14;
var sideOffset = this.offset[this.axis];
var absOffset = Math.abs(this.offset[this.axis]);
var absReverseOffset = Math.abs(this.offset[constant_1.OPPSITE[this.axis]]);
// 是在沿着 axis 滑动
var isSwipeOnTheDir = absReverseOffset < absOffset;
if (absOffset >= threshold && isSwipeOnTheDir && this.activePage !== constant_1.EMPTY_PAGE) {
this.pageChange = true;
this._swipeTo();
}
else {
this.pageChange = false;
this._swipeTo();
this.fire('swipeRestore');
}
};
Swiper.prototype.resizeHandler = function () {
if (!this.sliding && !this.moving) {
this.sideLength = this.axis === 'X' ? this.$container.clientWidth : this.$container.clientHeight;
}
};
Swiper.prototype.transitionEndHandler = function (event) {
if (event && event.target !== this.currentPage) {
return;
}
this.$swiper.style.cssText = '';
this.currentPage.style.cssText = '';
this.activePage.style.cssText = '';
// 回弹
if (this.pageChange === false) {
this.activePage.classList.remove('active');
this.fire('swipeRestored');
}
else {
this.currentPage.classList.remove('current');
this.activePage.classList.remove('active');
this.activePage.classList.add('current');
this.currentPage = this.activePage;
this.fire('swipeChanged');
}
this.activePage = constant_1.EMPTY_PAGE;
this.lastActivePage = constant_1.EMPTY_PAGE;
this.offset.X = 0;
this.offset.Y = 0;
this.sliding = false;
this.pageChange = false;
};
Swiper.prototype.swipeTo = function (toIndex, transition) {
if (this.sliding) {
return;
}
var currentIndex = this.currentPage.index;
this.moveDirection = interface_1.Direction.Nonward;
this.pageChange = true;
if (toIndex > currentIndex) {
this.moveDirection = interface_1.Direction.Forward;
}
else if (toIndex < currentIndex) {
this.moveDirection = interface_1.Direction.Backward;
}
var activeIndex = this.isLoop ? (toIndex + this.data.length) % this.data.length : toIndex;
this.activePage = this.$pages[activeIndex] || constant_1.EMPTY_PAGE;
// if the same, do nothing
if (activeIndex === currentIndex || this.activePage === constant_1.EMPTY_PAGE) {
this.pageChange = false;
}
this.transition = __assign({}, this.transition, this.currentPage.transition, transition);
this.renderInstance = render_1.default.getRenderInstance(this.transition.name);
// 外部调用仍然需要 fire activePageChanged 事件
this.fire('activePageChanged');
this.render();
this._swipeTo();
};
Swiper.prototype.swipePrev = function (transition) {
var currentIndex = this.currentPage.index;
this.swipeTo(currentIndex - 1, transition);
};
Swiper.prototype.swipeNext = function (transition) {
var currentIndex = this.currentPage.index;
this.swipeTo(currentIndex + 1, transition);
};
Swiper.prototype.getCurrentIndex = function () {
return this.currentPage.index;
};
Swiper.prototype._swipeTo = function () {
if (this.sliding) {
return;
}
this.sliding = true;
var duration = this.activePage === constant_1.EMPTY_PAGE ? 300 : this.transition.duration;
var elapsedTime = Math.abs(this.offset[this.axis]) / this.sideLength * duration;
var remainingTime = duration - elapsedTime;
var animateTime = this.pageChange ? remainingTime : elapsedTime;
var endOffset = this.pageChange ? this.moveDirection * this.sideLength : 0;
if (animateTime === 0) {
return this.transitionEndHandler();
}
// force the animation works
setTimeout(function () {
this.currentPage.style.webkitTransition = "ease-out " + animateTime + "ms";
if (this.activePage !== constant_1.EMPTY_PAGE) {
this.activePage.style.webkitTransition = "ease-out " + animateTime + "ms";
}
// set final offset
this.offset[this.axis] = endOffset;
this.render();
}.bind(this), 30);
};
Swiper.prototype.initRender = function () {
var _this = this;
this.$swiper = document.createElement('div');
this.$swiper.classList.add('lg-swiper');
this.$pages = this.data.map(function (page, index) {
var $page = document.createElement('div');
$page.classList.add('lg-swiper-page');
if (typeof page.content === 'string') {
$page.innerHTML = page.content;
}
else {
$page.appendChild(page.content);
}
$page.index = index;
$page.transition = page.transition;
if (_this.initIndex === index) {
$page.classList.add('current');
_this.currentPage = $page;
}
_this.$swiper.appendChild($page);
return $page;
});
this.$pages.forEach(function ($page, index, $pages) {
var prevIndex = _this.isLoop ? ($pages.length + index - 1) % $pages.length : (index - 1);
var nextIndex = _this.isLoop ? ($pages.length + index + 1) % $pages.length : (index + 1);
$page.prev = _this.$pages[prevIndex] || constant_1.EMPTY_PAGE;
$page.next = _this.$pages[nextIndex] || constant_1.EMPTY_PAGE;
});
this.$container.style.overflow = 'hidden';
this.$container.appendChild(this.$swiper);
};
Swiper.prototype.on = function (eventName, callback) {
var eventNames = eventName.split(' ');
for (var _i = 0, eventNames_1 = eventNames; _i < eventNames_1.length; _i++) {
var eventName_1 = eventNames_1[_i];
if (!this._listeners[eventName_1]) {
this._listeners[eventName_1] = [];
}
this._listeners[eventName_1].push(callback);
}
return this;
};
Swiper.prototype.off = function (eventName, callback) {
if (this._listeners[eventName]) {
var index = this._listeners[eventName].indexOf(callback);
if (index > -1) {
this._listeners[eventName].splice(index, 1);
}
}
return this;
};
Swiper.prototype.fire = function (eventName, event) {
if (event === void 0) { event = {}; }
if (this._listeners[eventName]) {
for (var _i = 0, _a = this._listeners[eventName]; _i < _a.length; _i++) {
var callback = _a[_i];
var extendArgs = __assign({}, event, { name: eventName });
callback.call(this, extendArgs);
}
}
return this;
};
Swiper.prototype.destroy = function () {
this.unbindEvents();
this._listeners = {};
this.$container.style.overflow = '';
this.$swiper.parentElement.removeChild(this.$swiper);
this.fire('destroy');
};
Swiper.prototype.render = function () {
// 撤销旧样式
if (this.lastActivePage !== this.activePage) {
this.lastActivePage.classList.remove('active');
this.lastActivePage.style.cssText = '';
if (this.activePage !== constant_1.EMPTY_PAGE) {
this.activePage.classList.add('active');
}
}
this.log('offset : ' + this.offset[this.axis]);
// 普通渲染:计算
var easingFn = easing_1.default.easeOutQuad;
if (this.activePage === constant_1.EMPTY_PAGE) {
easingFn = easing_1.default.rubberBand;
}
this.renderInstance.doRender({
axis: this.axis,
moveDirection: this.moveDirection,
sideOffset: easingFn(this.offset[this.axis], this.sideLength),
sideLength: this.sideLength,
$swiper: this.$swiper,
currentPage: this.currentPage,
activePage: this.activePage
});
};
return Swiper;
}());
Swiper.Events = [
'swipeBeforeStart',
'swipeStart',
'swipeMoving',
'swipeChanged',
'swipeRestore',
'swipeRestored',
'activePageChanged',
'destroy'
];
Swiper.Device = new device_1.Device(window);
Swiper.DefaultOptions = {
container: document.body,
data: [],
debug: false,
isVertical: true,
isLoop: false,
initIndex: 0,
keepDefaultClasses: [],
transition: {
name: 'slide',
duration: 800
}
};
exports.Swiper = Swiper;
/***/ }),
/* 3 */
/***/ (function(module, exports) {
// removed by extract-text-webpack-plugin
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @file: device.js 关于 swiper 所在设备
* @class Device
*
* @author: zhangbobell
* @email: zhangbobell@163.com
* @created: 2017.06.26
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
;
var Device = (function () {
function Device(global) {
this.hasTouch = !!('ontouchstart' in global
|| (global.DocumentTouch && global.document instanceof global.DocumentTouch));
this.startEvent = this.hasTouch ? 'touchstart' : 'mousedown';
this.moveEvent = this.hasTouch ? 'touchmove' : 'mousemove';
this.endEvent = this.hasTouch ? 'touchend' : 'mouseup';
this.cancelEvent = this.hasTouch ? 'touchcancel' : 'mouseout';
this.transitionEvent = this.getTransitionEvent();
// orientationchange also trigger resize
this.resizeEvent = 'resize';
}
Device.prototype.getDeviceEvent = function (event) {
var position = this.hasTouch ? this.getTouchPosition(event) : this.getMousePosition(event);
return {
type: event.type,
position: position,
target: event.target,
button: event.button,
preventDefault: event.preventDefault.bind(event)
};
};
Device.prototype.getTouchPosition = function (event) {
if (event.targetTouches && event.targetTouches.length > 0) {
return {
X: event.targetTouches[0].pageX,
Y: event.targetTouches[0].pageY,
};
}
return {
X: undefined,
Y: undefined
};
};
Device.prototype.getMousePosition = function (event) {
if ('pageX' in event) {
return {
X: event.pageX,
Y: event.pageY
};
}
return {
X: undefined,
Y: undefined
};
};
Device.prototype.getTransitionEvent = function () {
var el = document.createElement('fakeelement');
var transitions = {
'transition': 'transitionend',
'OTransition': 'oTransitionEnd',
'MozTransition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd'
};
for (var t in transitions) {
if (el.style[t] !== undefined) {
return transitions[t];
}
}
};
return Device;
}());
exports.Device = Device;
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Direction;
(function (Direction) {
Direction[Direction["Forward"] = -1] = "Forward";
Direction[Direction["Nonward"] = 0] = "Nonward";
Direction[Direction["Backward"] = 1] = "Backward";
})(Direction = exports.Direction || (exports.Direction = {}));
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @file easing.ts 缓动效果类,主要提供计算映射的函数
*
* @author: zhangbobell
* @email: zhangbobell@163.com
*
* @created: 2017.07.11
*/
Object.defineProperty(exports, "__esModule", { value: true });
var Easing = (function () {
function Easing() {
}
Easing.easeOutQuad = function (sideOffset, sideLength) {
var t = Math.abs(sideOffset / sideLength);
var y = 0.5 * t * (3 - t);
return Easing.sign(sideOffset) * y * sideLength;
};
Easing.rubberBand = function (sideOffset, sideLength) {
var t = Math.abs(sideOffset / sideLength);
var d = sideLength;
var y = 1.0 - (1.0 / ((0.55 * t) + 1.0));
return Easing.sign(sideOffset) * y * sideLength;
};
Easing.sign = function (x) {
x = +x;
if (x === 0 || isNaN(x)) {
return 0;
}
return x > 0 ? 1 : -1;
};
return Easing;
}());
exports.default = Easing;
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @file fade.ts 演示稿翻页效果(默认)
*
* @author: zhangbobell
* @email: zhangbobell@163.com
*
* @created: 2017.06.27
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var render_1 = __webpack_require__(1);
var constant_1 = __webpack_require__(0);
var Slide = (function (_super) {
__extends(Slide, _super);
function Slide() {
return _super !== null && _super.apply(this, arguments) || this;
}
Slide.prototype.doRender = function (swiper) {
var axis = swiper.axis;
var sideOffset = swiper.sideOffset;
var sideLength = swiper.sideLength;
var moveDirection = swiper.moveDirection;
var currentTransform = "translateZ(0) translate" + axis + "(" + sideOffset + "px)";
var activeTransform = "translateZ(0) translate" + axis + "(" + (sideOffset - moveDirection * sideLength) + "px)";
swiper.currentPage.style.webkitTransform = currentTransform;
if (swiper.activePage !== constant_1.EMPTY_PAGE) {
swiper.activePage.style.webkitTransform = activeTransform;
}
};
return Slide;
}(render_1.default));
exports.default = Slide;
/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @file rotate.ts 立方体翻页效果
*
* @author: zhangbobell
* @email: zhangbobell@163.com
*
* @created: 2017.06.27
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var render_1 = __webpack_require__(1);
var constant_1 = __webpack_require__(0);
var Rotate = (function (_super) {
__extends(Rotate, _super);
function Rotate() {
return _super !== null && _super.apply(this, arguments) || this;
}
Rotate.prototype.doRender = function (swiper) {
var axis = swiper.axis;
var sideOffset = swiper.sideOffset;
var sideLength = swiper.sideLength;
var rotateAxis = constant_1.OPPSITE[axis];
var moveDirection = swiper.moveDirection;
var rotateSign = axis === 'Y' ? -1 : 1;
// compute
var swiperCss = "-webkit-perspective:" + sideLength * 4 + "px;-webkit-transform-style:preserve-3d;";
var currentTransform = "rotate" + rotateAxis + "(" + rotateSign * 90 * sideOffset / sideLength + "deg) translateZ(" + 0.889 * sideLength / 2 + "px) scale(0.889)";
var activeTransform = "rotate" + rotateAxis + "(" + rotateSign * 90 * (sideOffset / sideLength - moveDirection) + "deg) translateZ(" + 0.889 * sideLength / 2 + "px) scale(0.889)";
// apply
swiper.$swiper.style.cssText = swiperCss;
swiper.currentPage.style.webkitTransform = currentTransform;
if (swiper.activePage !== constant_1.EMPTY_PAGE) {
swiper.activePage.style.webkitTransform = activeTransform;
}
};
return Rotate;
}(render_1.default));
exports.default = Rotate;
/***/ }),
/* 9 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @file fade.ts 翻转翻页效果
*
* @author: zhangbobell
* @email: zhangbobell@163.com
*
* @created: 2017.06.27
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var render_1 = __webpack_require__(1);
var constant_1 = __webpack_require__(0);
var Flip = (function (_super) {
__extends(Flip, _super);
function Flip() {
return _super !== null && _super.apply(this, arguments) || this;
}
Flip.prototype.doRender = function (swiper) {
var axis = swiper.axis;
var sideOffset = swiper.sideOffset;
var sideLength = swiper.sideLength;
var rotateAxis = constant_1.OPPSITE[axis];
var rotateSign = axis === 'Y' ? -1 : 1;
// compute
var swiperCss = "-webkit-perspective:" + sideLength * 4 + "px;-webkit-transform-style:flat;";
var currentTransform = "translateZ(" + sideLength / 2 + "px) rotate" + rotateAxis + "(" + rotateSign * 180 * sideOffset / sideLength + "deg) scale(0.875)";
var activeTransform = "translateZ(" + sideLength / 2 + "px) rotate" + rotateAxis + "(" + rotateSign * 180 * (sideOffset / sideLength + 1) + "deg) scale(0.875)";
// apply
swiper.$swiper.style.cssText = swiperCss;
swiper.currentPage.style.webkitBackfaceVisibility = 'hidden';
swiper.currentPage.style.webkitTransform = currentTransform;
if (swiper.activePage !== constant_1.EMPTY_PAGE) {
swiper.activePage.style.webkitBackfaceVisibility = 'hidden';
swiper.activePage.style.webkitTransform = activeTransform;
swiper.activePage.style.zIndex = 7;
}
};
return Flip;
}(render_1.default));
exports.default = Flip;
/***/ }),
/* 10 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @file card.ts 卡片翻页效果
*
* @author: zhangbobell
* @email: zhangbobell@163.com
*
* @created: 2017.06.27
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var render_1 = __webpack_require__(1);
var constant_1 = __webpack_require__(0);
var Card = (function (_super) {
__extends(Card, _super);
function Card() {
return _super !== null && _super.apply(this, arguments) || this;
}
Card.prototype.doRender = function (swiper) {
var axis = swiper.axis;
var sideOffset = swiper.sideOffset;
var sideLength = swiper.sideLength;
var scaleAxis = constant_1.OPPSITE[axis];
var scaleRatio = 1 - 0.2 * Math.abs(sideOffset / sideLength);
var moveDirection = swiper.moveDirection;
// compute
var currentTransform = "translateZ(0) scale" + scaleAxis + "(" + scaleRatio + ") translate" + axis + "(" + sideOffset + "px)";
var activeTransform = "translateZ(0) translate" + axis + "(" + (sideOffset - moveDirection * sideLength) + "px)";
// apply
swiper.currentPage.style.webkitTransform = currentTransform;
if (swiper.activePage !== constant_1.EMPTY_PAGE) {
swiper.activePage.style.webkitTransform = activeTransform;
}
};
return Card;
}(render_1.default));
exports.default = Card;
/***/ }),
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @file fade.ts 渐隐翻页效果
*
* @author: zhangbobell
* @email: zhangbobell@163.com
*
* @created: 2017.06.27
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var render_1 = __webpack_require__(1);
var constant_1 = __webpack_require__(0);
var Fade = (function (_super) {
__extends(Fade, _super);
function Fade() {
return _super !== null && _super.apply(this, arguments) || this;
}
Fade.prototype.doRender = function (swiper) {
var axis = swiper.axis;
var sideOffset = swiper.sideOffset;
var sideLength = swiper.sideLength;
// apply
swiper.currentPage.style.opacity = 1 - Math.abs(sideOffset / sideLength);
if (swiper.activePage !== constant_1.EMPTY_PAGE) {
swiper.activePage.style.opacity = Math.abs(sideOffset / sideLength);
}
};
return Fade;
}(render_1.default));
exports.default = Fade;
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* @file card.ts 度秘 3.0 新版引导页翻页效果
*
* 两个页面都有缩放效果,暂时没有想到合适名字
*
* @author: zhangbobell
* @email: zhangbobell@163.com
*
* @created: 2017.06.29
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var render_1 = __webpack_require__(1);
var constant_1 = __webpack_require__(0);
var Dumi = (function (_super) {
__extends(Dumi, _super);
function Dumi() {
return _super !== null && _super.apply(this, arguments) || this;
}
Dumi.prototype.doRender = function (swiper) {
var axis = swiper.axis;
var sideOffset = swiper.sideOffset;
var sideLength = swiper.sideLength;
var scaleAxis = constant_1.OPPSITE[axis];
var currentRatio = 1 - 0.4 * Math.min(Math.abs(sideOffset / sideLength), 0.5);
var activeRatio = 0.8 + 0.4 * Math.min(Math.abs(sideOffset / sideLength), 0.5);
var moveDirection = swiper.moveDirection;
// compute
var currentTransform = "translateZ(0) translate" + axis + "(" + sideOffset + "px) scale(" + currentRatio + ")";
var activeTransform = "translateZ(0) translate" + axis + "(" + (sideOffset - moveDirection * sideLength) + "px) scale(" + activeRatio + ")";
// apply
swiper.currentPage.style.webkitTransform = currentTransform;
if (swiper.activePage !== constant_1.EMPTY_PAGE) {
swiper.activePage.style.webkitTransform = activeTransform;
}
};
return Dumi;
}(render_1.default));
exports.default = Dumi;
/***/ })
/******/ ]);
});

2

package.json
{
"name": "fex-swiper",
"version": "1.0.2",
"version": "1.0.3",
"description": "a H5 swiper powered by FEX",

@@ -5,0 +5,0 @@ "main": "src/swiper.ts",

@@ -97,8 +97,8 @@ # Swiper

isLoop | boolean | `false` |是否开启循环翻页
keepDefaultClass | string[] | [] | 保持默认行为的 class 名,详见[说明](#about-keepdefault)
keepDefaultClasses | string[] | [] | 保持默认行为的 class 名,详见[说明](#about-keepdefault)
transition | [Transition](#transition) | `{name: 'slide', duration: 800}` | 翻页过渡动画,按照优先级取值,详见[优先级](#about-transition-priority)
**关于 keepDefaultClass 说明**<a name="about-keepdefault"></a>
**关于 keepDefaultClasses 说明**<a name="about-keepdefault"></a>
为防止滑动事件中断,Swiper 默认阻止所有除了 `a`, `input`, `textarea`, `select` 以外的所有元素的滑动事件(mouseXXX, touchXXX)默认行为。但是在实际项目中,可能还有一些元素需要被排除在外(如微信中,长按图片会有识别二维码的响应,因此就需要将该图片的 className 放入该数组中)。因此 `keepDefaultClass` 就是一个 **要保持默认响应的元素 class 的白名单**。
为防止滑动事件中断,Swiper 默认阻止所有除了 `a`, `input`, `textarea`, `select` 以外的所有元素的滑动事件(mouseXXX, touchXXX)默认行为。但是在实际项目中,可能还有一些元素需要被排除在外(如微信中,长按图片会有识别二维码的响应,因此就需要将该图片的 className 放入该数组中),加入到 keepDefaultClasses 的元素及其 **后代元素** 均会被排除在外。因此 `keepDefaultClasses` 就是一个 **要保持默认响应的元素 class 的白名单**。

@@ -105,0 +105,0 @@ **过渡效果优先级**<a name="about-transition-priority"></a>

@@ -188,5 +188,7 @@ /**

let keepDefaultClasses = this.keepDefaultClasses;
for (let keepDefaultClass of keepDefaultClasses){
if (event.target.classList.contains(keepDefaultClass)) {
return;
for (let keepDefaultClass of keepDefaultClasses) {
for (let e = event.target; e !== null; e = e.parentElement) {
if (e.classList.contains(keepDefaultClass)) {
return;
}
}

@@ -193,0 +195,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc