| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055 |
- module.exports =
- /******/ (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;
- /******/ // identity function for calling harmony imports with the correct context
- /******/ __webpack_require__.i = function(value) { return value; };
- /******/ // 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 = 235);
- /******/ })
- /************************************************************************/
- /******/ ({
- /***/ 0:
- /***/ function(module, exports) {
- /* globals __VUE_SSR_CONTEXT__ */
- // this module is a runtime utility for cleaner component module output and will
- // be included in the final webpack user bundle
- module.exports = function normalizeComponent (
- rawScriptExports,
- compiledTemplate,
- injectStyles,
- scopeId,
- moduleIdentifier /* server only */
- ) {
- var esModule
- var scriptExports = rawScriptExports = rawScriptExports || {}
- // ES6 modules interop
- var type = typeof rawScriptExports.default
- if (type === 'object' || type === 'function') {
- esModule = rawScriptExports
- scriptExports = rawScriptExports.default
- }
- // Vue.extend constructor export interop
- var options = typeof scriptExports === 'function'
- ? scriptExports.options
- : scriptExports
- // render functions
- if (compiledTemplate) {
- options.render = compiledTemplate.render
- options.staticRenderFns = compiledTemplate.staticRenderFns
- }
- // scopedId
- if (scopeId) {
- options._scopeId = scopeId
- }
- var hook
- if (moduleIdentifier) { // server build
- hook = function (context) {
- // 2.3 injection
- context =
- context || // cached call
- (this.$vnode && this.$vnode.ssrContext) || // stateful
- (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
- // 2.2 with runInNewContext: true
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
- context = __VUE_SSR_CONTEXT__
- }
- // inject component styles
- if (injectStyles) {
- injectStyles.call(this, context)
- }
- // register component module identifier for async chunk inferrence
- if (context && context._registeredComponents) {
- context._registeredComponents.add(moduleIdentifier)
- }
- }
- // used by ssr in case component is cached and beforeCreate
- // never gets called
- options._ssrRegister = hook
- } else if (injectStyles) {
- hook = injectStyles
- }
- if (hook) {
- var functional = options.functional
- var existing = functional
- ? options.render
- : options.beforeCreate
- if (!functional) {
- // inject component registration as beforeCreate hook
- options.beforeCreate = existing
- ? [].concat(existing, hook)
- : [hook]
- } else {
- // register for functioal component in vue file
- options.render = function renderWithStyleInjection (h, context) {
- hook.call(context)
- return existing(h, context)
- }
- }
- }
- return {
- esModule: esModule,
- exports: scriptExports,
- options: options
- }
- }
- /***/ },
- /***/ 1:
- /***/ function(module, exports) {
- module.exports = require("vue");
- /***/ },
- /***/ 158:
- /***/ function(module, exports, __webpack_require__) {
- function injectStyle (ssrContext) {
- __webpack_require__(99)
- }
- var Component = __webpack_require__(0)(
- /* script */
- __webpack_require__(80),
- /* template */
- __webpack_require__(168),
- /* styles */
- injectStyle,
- /* scopeId */
- null,
- /* moduleIdentifier (server only) */
- null
- )
- module.exports = Component.exports
- /***/ },
- /***/ 168:
- /***/ function(module, exports) {
- module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
- return _c('div', {
- staticClass: "mint-swipe"
- }, [_c('div', {
- ref: "wrap",
- staticClass: "mint-swipe-items-wrap"
- }, [_vm._t("default")], 2), _vm._v(" "), _c('div', {
- directives: [{
- name: "show",
- rawName: "v-show",
- value: (_vm.showIndicators),
- expression: "showIndicators"
- }],
- staticClass: "mint-swipe-indicators"
- }, _vm._l((_vm.pages), function(page, $index) {
- return _c('div', {
- staticClass: "mint-swipe-indicator",
- class: {
- 'is-active': $index === _vm.index
- }
- })
- }))])
- },staticRenderFns: []}
- /***/ },
- /***/ 2:
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue__ = __webpack_require__(1);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_vue__);
- /* unused harmony export on */
- /* unused harmony export off */
- /* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return once; });
- /* unused harmony export hasClass */
- /* harmony export (immutable) */ exports["a"] = addClass;
- /* harmony export (immutable) */ exports["b"] = removeClass;
- /* unused harmony export getStyle */
- /* unused harmony export setStyle */
- /* istanbul ignore next */
- var isServer = __WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer;
- var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
- var MOZ_HACK_REGEXP = /^moz([A-Z])/;
- var ieVersion = isServer ? 0 : Number(document.documentMode);
- /* istanbul ignore next */
- var trim = function(string) {
- return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
- };
- /* istanbul ignore next */
- var camelCase = function(name) {
- return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
- return offset ? letter.toUpperCase() : letter;
- }).replace(MOZ_HACK_REGEXP, 'Moz$1');
- };
- /* istanbul ignore next */
- var on = (function() {
- if (!isServer && document.addEventListener) {
- return function(element, event, handler) {
- if (element && event && handler) {
- element.addEventListener(event, handler, false);
- }
- };
- } else {
- return function(element, event, handler) {
- if (element && event && handler) {
- element.attachEvent('on' + event, handler);
- }
- };
- }
- })();
- /* istanbul ignore next */
- var off = (function() {
- if (!isServer && document.removeEventListener) {
- return function(element, event, handler) {
- if (element && event) {
- element.removeEventListener(event, handler, false);
- }
- };
- } else {
- return function(element, event, handler) {
- if (element && event) {
- element.detachEvent('on' + event, handler);
- }
- };
- }
- })();
- /* istanbul ignore next */
- var once = function(el, event, fn) {
- var listener = function() {
- if (fn) {
- fn.apply(this, arguments);
- }
- off(el, event, listener);
- };
- on(el, event, listener);
- };
- /* istanbul ignore next */
- function hasClass(el, cls) {
- if (!el || !cls) return false;
- if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.');
- if (el.classList) {
- return el.classList.contains(cls);
- } else {
- return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
- }
- };
- /* istanbul ignore next */
- function addClass(el, cls) {
- if (!el) return;
- var curClass = el.className;
- var classes = (cls || '').split(' ');
- for (var i = 0, j = classes.length; i < j; i++) {
- var clsName = classes[i];
- if (!clsName) continue;
- if (el.classList) {
- el.classList.add(clsName);
- } else {
- if (!hasClass(el, clsName)) {
- curClass += ' ' + clsName;
- }
- }
- }
- if (!el.classList) {
- el.className = curClass;
- }
- };
- /* istanbul ignore next */
- function removeClass(el, cls) {
- if (!el || !cls) return;
- var classes = cls.split(' ');
- var curClass = ' ' + el.className + ' ';
- for (var i = 0, j = classes.length; i < j; i++) {
- var clsName = classes[i];
- if (!clsName) continue;
- if (el.classList) {
- el.classList.remove(clsName);
- } else {
- if (hasClass(el, clsName)) {
- curClass = curClass.replace(' ' + clsName + ' ', ' ');
- }
- }
- }
- if (!el.classList) {
- el.className = trim(curClass);
- }
- };
- /* istanbul ignore next */
- var getStyle = ieVersion < 9 ? function(element, styleName) {
- if (isServer) return;
- if (!element || !styleName) return null;
- styleName = camelCase(styleName);
- if (styleName === 'float') {
- styleName = 'styleFloat';
- }
- try {
- switch (styleName) {
- case 'opacity':
- try {
- return element.filters.item('alpha').opacity / 100;
- } catch (e) {
- return 1.0;
- }
- default:
- return (element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null);
- }
- } catch (e) {
- return element.style[styleName];
- }
- } : function(element, styleName) {
- if (isServer) return;
- if (!element || !styleName) return null;
- styleName = camelCase(styleName);
- if (styleName === 'float') {
- styleName = 'cssFloat';
- }
- try {
- var computed = document.defaultView.getComputedStyle(element, '');
- return element.style[styleName] || computed ? computed[styleName] : null;
- } catch (e) {
- return element.style[styleName];
- }
- };
- /* istanbul ignore next */
- function setStyle(element, styleName, value) {
- if (!element || !styleName) return;
- if (typeof styleName === 'object') {
- for (var prop in styleName) {
- if (styleName.hasOwnProperty(prop)) {
- setStyle(element, prop, styleName[prop]);
- }
- }
- } else {
- styleName = camelCase(styleName);
- if (styleName === 'opacity' && ieVersion < 9) {
- element.style.filter = isNaN(value) ? '' : 'alpha(opacity=' + value * 100 + ')';
- } else {
- element.style[styleName] = value;
- }
- }
- };
- /***/ },
- /***/ 235:
- /***/ function(module, exports, __webpack_require__) {
- module.exports = __webpack_require__(44);
- /***/ },
- /***/ 44:
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_swipe_vue__ = __webpack_require__(158);
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_swipe_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__src_swipe_vue__);
- Object.defineProperty(exports, "__esModule", { value: true });
- /* harmony reexport (default from non-hamory) */ __webpack_require__.d(exports, "default", function() { return __WEBPACK_IMPORTED_MODULE_0__src_swipe_vue___default.a; });
- /***/ },
- /***/ 80:
- /***/ function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__ = __webpack_require__(2);
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- //
- /* harmony default export */ exports["default"] = {
- name: 'mt-swipe',
- created: function created() {
- this.dragState = {};
- },
- data: function data() {
- return {
- ready: false,
- dragging: false,
- userScrolling: false,
- animating: false,
- index: 0,
- pages: [],
- timer: null,
- reInitTimer: null,
- noDrag: false,
- isDone: false
- };
- },
- props: {
- speed: {
- type: Number,
- default: 300
- },
- defaultIndex: {
- type: Number,
- default: 0
- },
- auto: {
- type: Number,
- default: 3000
- },
- continuous: {
- type: Boolean,
- default: true
- },
- showIndicators: {
- type: Boolean,
- default: true
- },
- noDragWhenSingle: {
- type: Boolean,
- default: true
- },
- prevent: {
- type: Boolean,
- default: false
- },
- stopPropagation: {
- type: Boolean,
- default: false
- }
- },
- watch: {
- index: function index(newIndex) {
- this.$emit('change', newIndex);
- }
- },
- methods: {
- swipeItemCreated: function swipeItemCreated() {
- var this$1 = this;
- if (!this.ready) return;
- clearTimeout(this.reInitTimer);
- this.reInitTimer = setTimeout(function () {
- this$1.reInitPages();
- }, 100);
- },
- swipeItemDestroyed: function swipeItemDestroyed() {
- var this$1 = this;
- if (!this.ready) return;
- clearTimeout(this.reInitTimer);
- this.reInitTimer = setTimeout(function () {
- this$1.reInitPages();
- }, 100);
- },
- rafTranslate: function rafTranslate(element, initOffset, offset, callback, nextElement) {
- var ALPHA = 0.88;
- this.animating = true;
- var _offset = initOffset;
- var raf = 0;
- function animationLoop() {
- if (Math.abs(_offset - offset) < 0.5) {
- this.animating = false;
- _offset = offset;
- element.style.webkitTransform = '';
- if (nextElement) {
- nextElement.style.webkitTransform = '';
- }
- cancelAnimationFrame(raf);
- if (callback) {
- callback();
- }
- return;
- }
- _offset = ALPHA * _offset + (1.0 - ALPHA) * offset;
- element.style.webkitTransform = "translate3d(" + _offset + "px, 0, 0)";
- if (nextElement) {
- nextElement.style.webkitTransform = "translate3d(" + (_offset - offset) + "px, 0, 0)";
- }
- raf = requestAnimationFrame(animationLoop.bind(this));
- }
- animationLoop.call(this);
- },
- translate: function translate(element, offset, speed, callback) {
- var arguments$1 = arguments;
- var this$1 = this;
- if (speed) {
- this.animating = true;
- element.style.webkitTransition = '-webkit-transform ' + speed + 'ms ease-in-out';
- setTimeout(function () {
- element.style.webkitTransform = "translate3d(" + offset + "px, 0, 0)";
- }, 50);
- var called = false;
- var transitionEndCallback = function () {
- if (called) return;
- called = true;
- this$1.animating = false;
- element.style.webkitTransition = '';
- element.style.webkitTransform = '';
- if (callback) {
- callback.apply(this$1, arguments$1);
- }
- };
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__["c" /* once */])(element, 'webkitTransitionEnd', transitionEndCallback);
- setTimeout(transitionEndCallback, speed + 100); // webkitTransitionEnd maybe not fire on lower version android.
- } else {
- element.style.webkitTransition = '';
- element.style.webkitTransform = "translate3d(" + offset + "px, 0, 0)";
- }
- },
- reInitPages: function reInitPages() {
- var children = this.$children;
- this.noDrag = children.length === 1 && this.noDragWhenSingle;
- var pages = [];
- var intDefaultIndex = Math.floor(this.defaultIndex);
- var defaultIndex = (intDefaultIndex >= 0 && intDefaultIndex < children.length) ? intDefaultIndex : 0;
- this.index = defaultIndex;
- children.forEach(function(child, index) {
- pages.push(child.$el);
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__["b" /* removeClass */])(child.$el, 'is-active');
- if (index === defaultIndex) {
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__["a" /* addClass */])(child.$el, 'is-active');
- }
- });
- this.pages = pages;
- },
- doAnimate: function doAnimate(towards, options) {
- var this$1 = this;
- if (this.$children.length === 0) return;
- if (!options && this.$children.length < 2) return;
- var prevPage, nextPage, currentPage, pageWidth, offsetLeft, speedX;
- var speed = this.speed || 300;
- var index = this.index;
- var pages = this.pages;
- var pageCount = pages.length;
- if (!options) {
- pageWidth = this.$el.clientWidth;
- currentPage = pages[index];
- prevPage = pages[index - 1];
- nextPage = pages[index + 1];
- if (this.continuous && pages.length > 1) {
- if (!prevPage) {
- prevPage = pages[pages.length - 1];
- }
- if (!nextPage) {
- nextPage = pages[0];
- }
- }
- if (prevPage) {
- prevPage.style.display = 'block';
- this.translate(prevPage, -pageWidth);
- }
- if (nextPage) {
- nextPage.style.display = 'block';
- this.translate(nextPage, pageWidth);
- }
- } else {
- prevPage = options.prevPage;
- currentPage = options.currentPage;
- nextPage = options.nextPage;
- pageWidth = options.pageWidth;
- offsetLeft = options.offsetLeft;
- speedX = options.speedX;
- }
- var newIndex;
- var oldPage = this.$children[index].$el;
- if (towards === 'prev') {
- if (index > 0) {
- newIndex = index - 1;
- }
- if (this.continuous && index === 0) {
- newIndex = pageCount - 1;
- }
- } else if (towards === 'next') {
- if (index < pageCount - 1) {
- newIndex = index + 1;
- }
- if (this.continuous && index === pageCount - 1) {
- newIndex = 0;
- }
- }
- var callback = function () {
- if (newIndex !== undefined) {
- var newPage = this$1.$children[newIndex].$el;
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__["b" /* removeClass */])(oldPage, 'is-active');
- __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__["a" /* addClass */])(newPage, 'is-active');
- this$1.index = newIndex;
- }
- if (this$1.isDone) {
- this$1.end();
- }
- if (prevPage) {
- prevPage.style.display = '';
- }
- if (nextPage) {
- nextPage.style.display = '';
- }
- };
- setTimeout(function () {
- if (towards === 'next') {
- this$1.isDone = true;
- this$1.before(currentPage);
- if (speedX) {
- this$1.rafTranslate(currentPage, offsetLeft, -pageWidth, callback, nextPage);
- } else {
- this$1.translate(currentPage, -pageWidth, speed, callback);
- if (nextPage) {
- this$1.translate(nextPage, 0, speed);
- }
- }
- } else if (towards === 'prev') {
- this$1.isDone = true;
- this$1.before(currentPage);
- if (speedX) {
- this$1.rafTranslate(currentPage, offsetLeft, pageWidth, callback, prevPage);
- } else {
- this$1.translate(currentPage, pageWidth, speed, callback);
- if (prevPage) {
- this$1.translate(prevPage, 0, speed);
- }
- }
- } else {
- this$1.isDone = false;
- this$1.translate(currentPage, 0, speed, callback);
- if (typeof offsetLeft !== 'undefined') {
- if (prevPage && offsetLeft > 0) {
- this$1.translate(prevPage, pageWidth * -1, speed);
- }
- if (nextPage && offsetLeft < 0) {
- this$1.translate(nextPage, pageWidth, speed);
- }
- } else {
- if (prevPage) {
- this$1.translate(prevPage, pageWidth * -1, speed);
- }
- if (nextPage) {
- this$1.translate(nextPage, pageWidth, speed);
- }
- }
- }
- }, 10);
- },
- next: function next() {
- this.doAnimate('next');
- },
- prev: function prev() {
- this.doAnimate('prev');
- },
- before: function before() {
- this.$emit('before', this.index);
- },
- end: function end() {
- this.$emit('end', this.index);
- },
- doOnTouchStart: function doOnTouchStart(event) {
- if (this.noDrag) return;
- var element = this.$el;
- var dragState = this.dragState;
- var touch = event.touches[0];
- dragState.startTime = new Date();
- dragState.startLeft = touch.pageX;
- dragState.startTop = touch.pageY;
- dragState.startTopAbsolute = touch.clientY;
- dragState.pageWidth = element.offsetWidth;
- dragState.pageHeight = element.offsetHeight;
- var prevPage = this.$children[this.index - 1];
- var dragPage = this.$children[this.index];
- var nextPage = this.$children[this.index + 1];
- if (this.continuous && this.pages.length > 1) {
- if (!prevPage) {
- prevPage = this.$children[this.$children.length - 1];
- }
- if (!nextPage) {
- nextPage = this.$children[0];
- }
- }
- dragState.prevPage = prevPage ? prevPage.$el : null;
- dragState.dragPage = dragPage ? dragPage.$el : null;
- dragState.nextPage = nextPage ? nextPage.$el : null;
- if (dragState.prevPage) {
- dragState.prevPage.style.display = 'block';
- }
- if (dragState.nextPage) {
- dragState.nextPage.style.display = 'block';
- }
- },
- doOnTouchMove: function doOnTouchMove(event) {
- if (this.noDrag) return;
- var dragState = this.dragState;
- var touch = event.touches[0];
- dragState.speedX = touch.pageX - dragState.currentLeft;
- dragState.currentLeft = touch.pageX;
- dragState.currentTop = touch.pageY;
- dragState.currentTopAbsolute = touch.clientY;
- var offsetLeft = dragState.currentLeft - dragState.startLeft;
- var offsetTop = dragState.currentTopAbsolute - dragState.startTopAbsolute;
- var distanceX = Math.abs(offsetLeft);
- var distanceY = Math.abs(offsetTop);
- if (distanceX < 5 || (distanceX >= 5 && distanceY >= 1.73 * distanceX)) {
- this.userScrolling = true;
- return;
- } else {
- this.userScrolling = false;
- event.preventDefault();
- }
- offsetLeft = Math.min(Math.max(-dragState.pageWidth + 1, offsetLeft), dragState.pageWidth - 1);
- var towards = offsetLeft < 0 ? 'next' : 'prev';
- if (dragState.prevPage && towards === 'prev') {
- this.translate(dragState.prevPage, offsetLeft - dragState.pageWidth);
- }
- this.translate(dragState.dragPage, offsetLeft);
- if (dragState.nextPage && towards === 'next') {
- this.translate(dragState.nextPage, offsetLeft + dragState.pageWidth);
- }
- },
- doOnTouchEnd: function doOnTouchEnd() {
- if (this.noDrag) return;
- var dragState = this.dragState;
- var dragDuration = new Date() - dragState.startTime;
- var towards = null;
- var offsetLeft = dragState.currentLeft - dragState.startLeft;
- var offsetTop = dragState.currentTop - dragState.startTop;
- var pageWidth = dragState.pageWidth;
- var index = this.index;
- var pageCount = this.pages.length;
- if (dragDuration < 300) {
- var fireTap = Math.abs(offsetLeft) < 5 && Math.abs(offsetTop) < 5;
- if (isNaN(offsetLeft) || isNaN(offsetTop)) {
- fireTap = true;
- }
- if (fireTap) {
- this.$children[this.index].$emit('tap');
- }
- }
- if (dragDuration < 300 && dragState.currentLeft === undefined) return;
- if (dragDuration < 300 || Math.abs(offsetLeft) > pageWidth / 2) {
- towards = offsetLeft < 0 ? 'next' : 'prev';
- }
- if (!this.continuous) {
- if ((index === 0 && towards === 'prev') || (index === pageCount - 1 && towards === 'next')) {
- towards = null;
- }
- }
- if (this.$children.length < 2) {
- towards = null;
- }
- this.doAnimate(towards, {
- offsetLeft: offsetLeft,
- pageWidth: dragState.pageWidth,
- prevPage: dragState.prevPage,
- currentPage: dragState.dragPage,
- nextPage: dragState.nextPage,
- speedX: dragState.speedX
- });
- this.dragState = {};
- },
- initTimer: function initTimer() {
- var this$1 = this;
- if (this.auto > 0 && !this.timer) {
- this.timer = setInterval(function () {
- if (!this$1.continuous && (this$1.index >= this$1.pages.length - 1)) {
- return this$1.clearTimer();
- }
- if (!this$1.dragging && !this$1.animating) {
- this$1.next();
- }
- }, this.auto);
- }
- },
- clearTimer: function clearTimer() {
- clearInterval(this.timer);
- this.timer = null;
- }
- },
- destroyed: function destroyed() {
- if (this.timer) {
- this.clearTimer();
- }
- if (this.reInitTimer) {
- clearTimeout(this.reInitTimer);
- this.reInitTimer = null;
- }
- },
- mounted: function mounted() {
- var this$1 = this;
- this.ready = true;
- this.initTimer();
- this.reInitPages();
- var element = this.$el;
- element.addEventListener('touchstart', function (event) {
- if (this$1.prevent) event.preventDefault();
- if (this$1.stopPropagation) event.stopPropagation();
- if (this$1.animating) return;
- this$1.dragging = true;
- this$1.userScrolling = false;
- this$1.doOnTouchStart(event);
- });
- element.addEventListener('touchmove', function (event) {
- if (!this$1.dragging) return;
- if (this$1.timer) this$1.clearTimer();
- this$1.doOnTouchMove(event);
- });
- element.addEventListener('touchend', function (event) {
- if (this$1.userScrolling) {
- this$1.dragging = false;
- this$1.dragState = {};
- return;
- }
- if (!this$1.dragging) return;
- this$1.initTimer();
- this$1.doOnTouchEnd(event);
- this$1.dragging = false;
- });
- }
- };
- /***/ },
- /***/ 99:
- /***/ function(module, exports) {
- // removed by extract-text-webpack-plugin
- /***/ }
- /******/ });
|