index.js 27 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  1. module.exports =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/ // The require function
  6. /******/ function __webpack_require__(moduleId) {
  7. /******/ // Check if module is in cache
  8. /******/ if(installedModules[moduleId])
  9. /******/ return installedModules[moduleId].exports;
  10. /******/ // Create a new module (and put it into the cache)
  11. /******/ var module = installedModules[moduleId] = {
  12. /******/ i: moduleId,
  13. /******/ l: false,
  14. /******/ exports: {}
  15. /******/ };
  16. /******/ // Execute the module function
  17. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  18. /******/ // Flag the module as loaded
  19. /******/ module.l = true;
  20. /******/ // Return the exports of the module
  21. /******/ return module.exports;
  22. /******/ }
  23. /******/ // expose the modules object (__webpack_modules__)
  24. /******/ __webpack_require__.m = modules;
  25. /******/ // expose the module cache
  26. /******/ __webpack_require__.c = installedModules;
  27. /******/ // identity function for calling harmony imports with the correct context
  28. /******/ __webpack_require__.i = function(value) { return value; };
  29. /******/ // define getter function for harmony exports
  30. /******/ __webpack_require__.d = function(exports, name, getter) {
  31. /******/ if(!__webpack_require__.o(exports, name)) {
  32. /******/ Object.defineProperty(exports, name, {
  33. /******/ configurable: false,
  34. /******/ enumerable: true,
  35. /******/ get: getter
  36. /******/ });
  37. /******/ }
  38. /******/ };
  39. /******/ // getDefaultExport function for compatibility with non-harmony modules
  40. /******/ __webpack_require__.n = function(module) {
  41. /******/ var getter = module && module.__esModule ?
  42. /******/ function getDefault() { return module['default']; } :
  43. /******/ function getModuleExports() { return module; };
  44. /******/ __webpack_require__.d(getter, 'a', getter);
  45. /******/ return getter;
  46. /******/ };
  47. /******/ // Object.prototype.hasOwnProperty.call
  48. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  49. /******/ // __webpack_public_path__
  50. /******/ __webpack_require__.p = "";
  51. /******/ // Load entry module and return exports
  52. /******/ return __webpack_require__(__webpack_require__.s = 235);
  53. /******/ })
  54. /************************************************************************/
  55. /******/ ({
  56. /***/ 0:
  57. /***/ function(module, exports) {
  58. /* globals __VUE_SSR_CONTEXT__ */
  59. // this module is a runtime utility for cleaner component module output and will
  60. // be included in the final webpack user bundle
  61. module.exports = function normalizeComponent (
  62. rawScriptExports,
  63. compiledTemplate,
  64. injectStyles,
  65. scopeId,
  66. moduleIdentifier /* server only */
  67. ) {
  68. var esModule
  69. var scriptExports = rawScriptExports = rawScriptExports || {}
  70. // ES6 modules interop
  71. var type = typeof rawScriptExports.default
  72. if (type === 'object' || type === 'function') {
  73. esModule = rawScriptExports
  74. scriptExports = rawScriptExports.default
  75. }
  76. // Vue.extend constructor export interop
  77. var options = typeof scriptExports === 'function'
  78. ? scriptExports.options
  79. : scriptExports
  80. // render functions
  81. if (compiledTemplate) {
  82. options.render = compiledTemplate.render
  83. options.staticRenderFns = compiledTemplate.staticRenderFns
  84. }
  85. // scopedId
  86. if (scopeId) {
  87. options._scopeId = scopeId
  88. }
  89. var hook
  90. if (moduleIdentifier) { // server build
  91. hook = function (context) {
  92. // 2.3 injection
  93. context =
  94. context || // cached call
  95. (this.$vnode && this.$vnode.ssrContext) || // stateful
  96. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  97. // 2.2 with runInNewContext: true
  98. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  99. context = __VUE_SSR_CONTEXT__
  100. }
  101. // inject component styles
  102. if (injectStyles) {
  103. injectStyles.call(this, context)
  104. }
  105. // register component module identifier for async chunk inferrence
  106. if (context && context._registeredComponents) {
  107. context._registeredComponents.add(moduleIdentifier)
  108. }
  109. }
  110. // used by ssr in case component is cached and beforeCreate
  111. // never gets called
  112. options._ssrRegister = hook
  113. } else if (injectStyles) {
  114. hook = injectStyles
  115. }
  116. if (hook) {
  117. var functional = options.functional
  118. var existing = functional
  119. ? options.render
  120. : options.beforeCreate
  121. if (!functional) {
  122. // inject component registration as beforeCreate hook
  123. options.beforeCreate = existing
  124. ? [].concat(existing, hook)
  125. : [hook]
  126. } else {
  127. // register for functioal component in vue file
  128. options.render = function renderWithStyleInjection (h, context) {
  129. hook.call(context)
  130. return existing(h, context)
  131. }
  132. }
  133. }
  134. return {
  135. esModule: esModule,
  136. exports: scriptExports,
  137. options: options
  138. }
  139. }
  140. /***/ },
  141. /***/ 1:
  142. /***/ function(module, exports) {
  143. module.exports = require("vue");
  144. /***/ },
  145. /***/ 158:
  146. /***/ function(module, exports, __webpack_require__) {
  147. function injectStyle (ssrContext) {
  148. __webpack_require__(99)
  149. }
  150. var Component = __webpack_require__(0)(
  151. /* script */
  152. __webpack_require__(80),
  153. /* template */
  154. __webpack_require__(168),
  155. /* styles */
  156. injectStyle,
  157. /* scopeId */
  158. null,
  159. /* moduleIdentifier (server only) */
  160. null
  161. )
  162. module.exports = Component.exports
  163. /***/ },
  164. /***/ 168:
  165. /***/ function(module, exports) {
  166. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  167. return _c('div', {
  168. staticClass: "mint-swipe"
  169. }, [_c('div', {
  170. ref: "wrap",
  171. staticClass: "mint-swipe-items-wrap"
  172. }, [_vm._t("default")], 2), _vm._v(" "), _c('div', {
  173. directives: [{
  174. name: "show",
  175. rawName: "v-show",
  176. value: (_vm.showIndicators),
  177. expression: "showIndicators"
  178. }],
  179. staticClass: "mint-swipe-indicators"
  180. }, _vm._l((_vm.pages), function(page, $index) {
  181. return _c('div', {
  182. staticClass: "mint-swipe-indicator",
  183. class: {
  184. 'is-active': $index === _vm.index
  185. }
  186. })
  187. }))])
  188. },staticRenderFns: []}
  189. /***/ },
  190. /***/ 2:
  191. /***/ function(module, exports, __webpack_require__) {
  192. "use strict";
  193. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue__ = __webpack_require__(1);
  194. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_vue__);
  195. /* unused harmony export on */
  196. /* unused harmony export off */
  197. /* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return once; });
  198. /* unused harmony export hasClass */
  199. /* harmony export (immutable) */ exports["a"] = addClass;
  200. /* harmony export (immutable) */ exports["b"] = removeClass;
  201. /* unused harmony export getStyle */
  202. /* unused harmony export setStyle */
  203. /* istanbul ignore next */
  204. var isServer = __WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer;
  205. var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
  206. var MOZ_HACK_REGEXP = /^moz([A-Z])/;
  207. var ieVersion = isServer ? 0 : Number(document.documentMode);
  208. /* istanbul ignore next */
  209. var trim = function(string) {
  210. return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
  211. };
  212. /* istanbul ignore next */
  213. var camelCase = function(name) {
  214. return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
  215. return offset ? letter.toUpperCase() : letter;
  216. }).replace(MOZ_HACK_REGEXP, 'Moz$1');
  217. };
  218. /* istanbul ignore next */
  219. var on = (function() {
  220. if (!isServer && document.addEventListener) {
  221. return function(element, event, handler) {
  222. if (element && event && handler) {
  223. element.addEventListener(event, handler, false);
  224. }
  225. };
  226. } else {
  227. return function(element, event, handler) {
  228. if (element && event && handler) {
  229. element.attachEvent('on' + event, handler);
  230. }
  231. };
  232. }
  233. })();
  234. /* istanbul ignore next */
  235. var off = (function() {
  236. if (!isServer && document.removeEventListener) {
  237. return function(element, event, handler) {
  238. if (element && event) {
  239. element.removeEventListener(event, handler, false);
  240. }
  241. };
  242. } else {
  243. return function(element, event, handler) {
  244. if (element && event) {
  245. element.detachEvent('on' + event, handler);
  246. }
  247. };
  248. }
  249. })();
  250. /* istanbul ignore next */
  251. var once = function(el, event, fn) {
  252. var listener = function() {
  253. if (fn) {
  254. fn.apply(this, arguments);
  255. }
  256. off(el, event, listener);
  257. };
  258. on(el, event, listener);
  259. };
  260. /* istanbul ignore next */
  261. function hasClass(el, cls) {
  262. if (!el || !cls) return false;
  263. if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.');
  264. if (el.classList) {
  265. return el.classList.contains(cls);
  266. } else {
  267. return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
  268. }
  269. };
  270. /* istanbul ignore next */
  271. function addClass(el, cls) {
  272. if (!el) return;
  273. var curClass = el.className;
  274. var classes = (cls || '').split(' ');
  275. for (var i = 0, j = classes.length; i < j; i++) {
  276. var clsName = classes[i];
  277. if (!clsName) continue;
  278. if (el.classList) {
  279. el.classList.add(clsName);
  280. } else {
  281. if (!hasClass(el, clsName)) {
  282. curClass += ' ' + clsName;
  283. }
  284. }
  285. }
  286. if (!el.classList) {
  287. el.className = curClass;
  288. }
  289. };
  290. /* istanbul ignore next */
  291. function removeClass(el, cls) {
  292. if (!el || !cls) return;
  293. var classes = cls.split(' ');
  294. var curClass = ' ' + el.className + ' ';
  295. for (var i = 0, j = classes.length; i < j; i++) {
  296. var clsName = classes[i];
  297. if (!clsName) continue;
  298. if (el.classList) {
  299. el.classList.remove(clsName);
  300. } else {
  301. if (hasClass(el, clsName)) {
  302. curClass = curClass.replace(' ' + clsName + ' ', ' ');
  303. }
  304. }
  305. }
  306. if (!el.classList) {
  307. el.className = trim(curClass);
  308. }
  309. };
  310. /* istanbul ignore next */
  311. var getStyle = ieVersion < 9 ? function(element, styleName) {
  312. if (isServer) return;
  313. if (!element || !styleName) return null;
  314. styleName = camelCase(styleName);
  315. if (styleName === 'float') {
  316. styleName = 'styleFloat';
  317. }
  318. try {
  319. switch (styleName) {
  320. case 'opacity':
  321. try {
  322. return element.filters.item('alpha').opacity / 100;
  323. } catch (e) {
  324. return 1.0;
  325. }
  326. default:
  327. return (element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null);
  328. }
  329. } catch (e) {
  330. return element.style[styleName];
  331. }
  332. } : function(element, styleName) {
  333. if (isServer) return;
  334. if (!element || !styleName) return null;
  335. styleName = camelCase(styleName);
  336. if (styleName === 'float') {
  337. styleName = 'cssFloat';
  338. }
  339. try {
  340. var computed = document.defaultView.getComputedStyle(element, '');
  341. return element.style[styleName] || computed ? computed[styleName] : null;
  342. } catch (e) {
  343. return element.style[styleName];
  344. }
  345. };
  346. /* istanbul ignore next */
  347. function setStyle(element, styleName, value) {
  348. if (!element || !styleName) return;
  349. if (typeof styleName === 'object') {
  350. for (var prop in styleName) {
  351. if (styleName.hasOwnProperty(prop)) {
  352. setStyle(element, prop, styleName[prop]);
  353. }
  354. }
  355. } else {
  356. styleName = camelCase(styleName);
  357. if (styleName === 'opacity' && ieVersion < 9) {
  358. element.style.filter = isNaN(value) ? '' : 'alpha(opacity=' + value * 100 + ')';
  359. } else {
  360. element.style[styleName] = value;
  361. }
  362. }
  363. };
  364. /***/ },
  365. /***/ 235:
  366. /***/ function(module, exports, __webpack_require__) {
  367. module.exports = __webpack_require__(44);
  368. /***/ },
  369. /***/ 44:
  370. /***/ function(module, exports, __webpack_require__) {
  371. "use strict";
  372. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_swipe_vue__ = __webpack_require__(158);
  373. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_swipe_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__src_swipe_vue__);
  374. Object.defineProperty(exports, "__esModule", { value: true });
  375. /* harmony reexport (default from non-hamory) */ __webpack_require__.d(exports, "default", function() { return __WEBPACK_IMPORTED_MODULE_0__src_swipe_vue___default.a; });
  376. /***/ },
  377. /***/ 80:
  378. /***/ function(module, exports, __webpack_require__) {
  379. "use strict";
  380. Object.defineProperty(exports, "__esModule", { value: true });
  381. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__ = __webpack_require__(2);
  382. //
  383. //
  384. //
  385. //
  386. //
  387. //
  388. //
  389. //
  390. //
  391. //
  392. //
  393. //
  394. //
  395. //
  396. //
  397. //
  398. //
  399. //
  400. //
  401. //
  402. //
  403. //
  404. //
  405. //
  406. //
  407. //
  408. //
  409. //
  410. //
  411. //
  412. //
  413. //
  414. //
  415. //
  416. //
  417. //
  418. //
  419. //
  420. //
  421. //
  422. //
  423. //
  424. //
  425. //
  426. //
  427. //
  428. //
  429. //
  430. //
  431. //
  432. //
  433. //
  434. //
  435. //
  436. //
  437. //
  438. //
  439. //
  440. //
  441. //
  442. //
  443. /* harmony default export */ exports["default"] = {
  444. name: 'mt-swipe',
  445. created: function created() {
  446. this.dragState = {};
  447. },
  448. data: function data() {
  449. return {
  450. ready: false,
  451. dragging: false,
  452. userScrolling: false,
  453. animating: false,
  454. index: 0,
  455. pages: [],
  456. timer: null,
  457. reInitTimer: null,
  458. noDrag: false,
  459. isDone: false
  460. };
  461. },
  462. props: {
  463. speed: {
  464. type: Number,
  465. default: 300
  466. },
  467. defaultIndex: {
  468. type: Number,
  469. default: 0
  470. },
  471. auto: {
  472. type: Number,
  473. default: 3000
  474. },
  475. continuous: {
  476. type: Boolean,
  477. default: true
  478. },
  479. showIndicators: {
  480. type: Boolean,
  481. default: true
  482. },
  483. noDragWhenSingle: {
  484. type: Boolean,
  485. default: true
  486. },
  487. prevent: {
  488. type: Boolean,
  489. default: false
  490. },
  491. stopPropagation: {
  492. type: Boolean,
  493. default: false
  494. }
  495. },
  496. watch: {
  497. index: function index(newIndex) {
  498. this.$emit('change', newIndex);
  499. }
  500. },
  501. methods: {
  502. swipeItemCreated: function swipeItemCreated() {
  503. var this$1 = this;
  504. if (!this.ready) return;
  505. clearTimeout(this.reInitTimer);
  506. this.reInitTimer = setTimeout(function () {
  507. this$1.reInitPages();
  508. }, 100);
  509. },
  510. swipeItemDestroyed: function swipeItemDestroyed() {
  511. var this$1 = this;
  512. if (!this.ready) return;
  513. clearTimeout(this.reInitTimer);
  514. this.reInitTimer = setTimeout(function () {
  515. this$1.reInitPages();
  516. }, 100);
  517. },
  518. rafTranslate: function rafTranslate(element, initOffset, offset, callback, nextElement) {
  519. var ALPHA = 0.88;
  520. this.animating = true;
  521. var _offset = initOffset;
  522. var raf = 0;
  523. function animationLoop() {
  524. if (Math.abs(_offset - offset) < 0.5) {
  525. this.animating = false;
  526. _offset = offset;
  527. element.style.webkitTransform = '';
  528. if (nextElement) {
  529. nextElement.style.webkitTransform = '';
  530. }
  531. cancelAnimationFrame(raf);
  532. if (callback) {
  533. callback();
  534. }
  535. return;
  536. }
  537. _offset = ALPHA * _offset + (1.0 - ALPHA) * offset;
  538. element.style.webkitTransform = "translate3d(" + _offset + "px, 0, 0)";
  539. if (nextElement) {
  540. nextElement.style.webkitTransform = "translate3d(" + (_offset - offset) + "px, 0, 0)";
  541. }
  542. raf = requestAnimationFrame(animationLoop.bind(this));
  543. }
  544. animationLoop.call(this);
  545. },
  546. translate: function translate(element, offset, speed, callback) {
  547. var arguments$1 = arguments;
  548. var this$1 = this;
  549. if (speed) {
  550. this.animating = true;
  551. element.style.webkitTransition = '-webkit-transform ' + speed + 'ms ease-in-out';
  552. setTimeout(function () {
  553. element.style.webkitTransform = "translate3d(" + offset + "px, 0, 0)";
  554. }, 50);
  555. var called = false;
  556. var transitionEndCallback = function () {
  557. if (called) return;
  558. called = true;
  559. this$1.animating = false;
  560. element.style.webkitTransition = '';
  561. element.style.webkitTransform = '';
  562. if (callback) {
  563. callback.apply(this$1, arguments$1);
  564. }
  565. };
  566. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__["c" /* once */])(element, 'webkitTransitionEnd', transitionEndCallback);
  567. setTimeout(transitionEndCallback, speed + 100); // webkitTransitionEnd maybe not fire on lower version android.
  568. } else {
  569. element.style.webkitTransition = '';
  570. element.style.webkitTransform = "translate3d(" + offset + "px, 0, 0)";
  571. }
  572. },
  573. reInitPages: function reInitPages() {
  574. var children = this.$children;
  575. this.noDrag = children.length === 1 && this.noDragWhenSingle;
  576. var pages = [];
  577. var intDefaultIndex = Math.floor(this.defaultIndex);
  578. var defaultIndex = (intDefaultIndex >= 0 && intDefaultIndex < children.length) ? intDefaultIndex : 0;
  579. this.index = defaultIndex;
  580. children.forEach(function(child, index) {
  581. pages.push(child.$el);
  582. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__["b" /* removeClass */])(child.$el, 'is-active');
  583. if (index === defaultIndex) {
  584. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__["a" /* addClass */])(child.$el, 'is-active');
  585. }
  586. });
  587. this.pages = pages;
  588. },
  589. doAnimate: function doAnimate(towards, options) {
  590. var this$1 = this;
  591. if (this.$children.length === 0) return;
  592. if (!options && this.$children.length < 2) return;
  593. var prevPage, nextPage, currentPage, pageWidth, offsetLeft, speedX;
  594. var speed = this.speed || 300;
  595. var index = this.index;
  596. var pages = this.pages;
  597. var pageCount = pages.length;
  598. if (!options) {
  599. pageWidth = this.$el.clientWidth;
  600. currentPage = pages[index];
  601. prevPage = pages[index - 1];
  602. nextPage = pages[index + 1];
  603. if (this.continuous && pages.length > 1) {
  604. if (!prevPage) {
  605. prevPage = pages[pages.length - 1];
  606. }
  607. if (!nextPage) {
  608. nextPage = pages[0];
  609. }
  610. }
  611. if (prevPage) {
  612. prevPage.style.display = 'block';
  613. this.translate(prevPage, -pageWidth);
  614. }
  615. if (nextPage) {
  616. nextPage.style.display = 'block';
  617. this.translate(nextPage, pageWidth);
  618. }
  619. } else {
  620. prevPage = options.prevPage;
  621. currentPage = options.currentPage;
  622. nextPage = options.nextPage;
  623. pageWidth = options.pageWidth;
  624. offsetLeft = options.offsetLeft;
  625. speedX = options.speedX;
  626. }
  627. var newIndex;
  628. var oldPage = this.$children[index].$el;
  629. if (towards === 'prev') {
  630. if (index > 0) {
  631. newIndex = index - 1;
  632. }
  633. if (this.continuous && index === 0) {
  634. newIndex = pageCount - 1;
  635. }
  636. } else if (towards === 'next') {
  637. if (index < pageCount - 1) {
  638. newIndex = index + 1;
  639. }
  640. if (this.continuous && index === pageCount - 1) {
  641. newIndex = 0;
  642. }
  643. }
  644. var callback = function () {
  645. if (newIndex !== undefined) {
  646. var newPage = this$1.$children[newIndex].$el;
  647. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__["b" /* removeClass */])(oldPage, 'is-active');
  648. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__["a" /* addClass */])(newPage, 'is-active');
  649. this$1.index = newIndex;
  650. }
  651. if (this$1.isDone) {
  652. this$1.end();
  653. }
  654. if (prevPage) {
  655. prevPage.style.display = '';
  656. }
  657. if (nextPage) {
  658. nextPage.style.display = '';
  659. }
  660. };
  661. setTimeout(function () {
  662. if (towards === 'next') {
  663. this$1.isDone = true;
  664. this$1.before(currentPage);
  665. if (speedX) {
  666. this$1.rafTranslate(currentPage, offsetLeft, -pageWidth, callback, nextPage);
  667. } else {
  668. this$1.translate(currentPage, -pageWidth, speed, callback);
  669. if (nextPage) {
  670. this$1.translate(nextPage, 0, speed);
  671. }
  672. }
  673. } else if (towards === 'prev') {
  674. this$1.isDone = true;
  675. this$1.before(currentPage);
  676. if (speedX) {
  677. this$1.rafTranslate(currentPage, offsetLeft, pageWidth, callback, prevPage);
  678. } else {
  679. this$1.translate(currentPage, pageWidth, speed, callback);
  680. if (prevPage) {
  681. this$1.translate(prevPage, 0, speed);
  682. }
  683. }
  684. } else {
  685. this$1.isDone = false;
  686. this$1.translate(currentPage, 0, speed, callback);
  687. if (typeof offsetLeft !== 'undefined') {
  688. if (prevPage && offsetLeft > 0) {
  689. this$1.translate(prevPage, pageWidth * -1, speed);
  690. }
  691. if (nextPage && offsetLeft < 0) {
  692. this$1.translate(nextPage, pageWidth, speed);
  693. }
  694. } else {
  695. if (prevPage) {
  696. this$1.translate(prevPage, pageWidth * -1, speed);
  697. }
  698. if (nextPage) {
  699. this$1.translate(nextPage, pageWidth, speed);
  700. }
  701. }
  702. }
  703. }, 10);
  704. },
  705. next: function next() {
  706. this.doAnimate('next');
  707. },
  708. prev: function prev() {
  709. this.doAnimate('prev');
  710. },
  711. before: function before() {
  712. this.$emit('before', this.index);
  713. },
  714. end: function end() {
  715. this.$emit('end', this.index);
  716. },
  717. doOnTouchStart: function doOnTouchStart(event) {
  718. if (this.noDrag) return;
  719. var element = this.$el;
  720. var dragState = this.dragState;
  721. var touch = event.touches[0];
  722. dragState.startTime = new Date();
  723. dragState.startLeft = touch.pageX;
  724. dragState.startTop = touch.pageY;
  725. dragState.startTopAbsolute = touch.clientY;
  726. dragState.pageWidth = element.offsetWidth;
  727. dragState.pageHeight = element.offsetHeight;
  728. var prevPage = this.$children[this.index - 1];
  729. var dragPage = this.$children[this.index];
  730. var nextPage = this.$children[this.index + 1];
  731. if (this.continuous && this.pages.length > 1) {
  732. if (!prevPage) {
  733. prevPage = this.$children[this.$children.length - 1];
  734. }
  735. if (!nextPage) {
  736. nextPage = this.$children[0];
  737. }
  738. }
  739. dragState.prevPage = prevPage ? prevPage.$el : null;
  740. dragState.dragPage = dragPage ? dragPage.$el : null;
  741. dragState.nextPage = nextPage ? nextPage.$el : null;
  742. if (dragState.prevPage) {
  743. dragState.prevPage.style.display = 'block';
  744. }
  745. if (dragState.nextPage) {
  746. dragState.nextPage.style.display = 'block';
  747. }
  748. },
  749. doOnTouchMove: function doOnTouchMove(event) {
  750. if (this.noDrag) return;
  751. var dragState = this.dragState;
  752. var touch = event.touches[0];
  753. dragState.speedX = touch.pageX - dragState.currentLeft;
  754. dragState.currentLeft = touch.pageX;
  755. dragState.currentTop = touch.pageY;
  756. dragState.currentTopAbsolute = touch.clientY;
  757. var offsetLeft = dragState.currentLeft - dragState.startLeft;
  758. var offsetTop = dragState.currentTopAbsolute - dragState.startTopAbsolute;
  759. var distanceX = Math.abs(offsetLeft);
  760. var distanceY = Math.abs(offsetTop);
  761. if (distanceX < 5 || (distanceX >= 5 && distanceY >= 1.73 * distanceX)) {
  762. this.userScrolling = true;
  763. return;
  764. } else {
  765. this.userScrolling = false;
  766. event.preventDefault();
  767. }
  768. offsetLeft = Math.min(Math.max(-dragState.pageWidth + 1, offsetLeft), dragState.pageWidth - 1);
  769. var towards = offsetLeft < 0 ? 'next' : 'prev';
  770. if (dragState.prevPage && towards === 'prev') {
  771. this.translate(dragState.prevPage, offsetLeft - dragState.pageWidth);
  772. }
  773. this.translate(dragState.dragPage, offsetLeft);
  774. if (dragState.nextPage && towards === 'next') {
  775. this.translate(dragState.nextPage, offsetLeft + dragState.pageWidth);
  776. }
  777. },
  778. doOnTouchEnd: function doOnTouchEnd() {
  779. if (this.noDrag) return;
  780. var dragState = this.dragState;
  781. var dragDuration = new Date() - dragState.startTime;
  782. var towards = null;
  783. var offsetLeft = dragState.currentLeft - dragState.startLeft;
  784. var offsetTop = dragState.currentTop - dragState.startTop;
  785. var pageWidth = dragState.pageWidth;
  786. var index = this.index;
  787. var pageCount = this.pages.length;
  788. if (dragDuration < 300) {
  789. var fireTap = Math.abs(offsetLeft) < 5 && Math.abs(offsetTop) < 5;
  790. if (isNaN(offsetLeft) || isNaN(offsetTop)) {
  791. fireTap = true;
  792. }
  793. if (fireTap) {
  794. this.$children[this.index].$emit('tap');
  795. }
  796. }
  797. if (dragDuration < 300 && dragState.currentLeft === undefined) return;
  798. if (dragDuration < 300 || Math.abs(offsetLeft) > pageWidth / 2) {
  799. towards = offsetLeft < 0 ? 'next' : 'prev';
  800. }
  801. if (!this.continuous) {
  802. if ((index === 0 && towards === 'prev') || (index === pageCount - 1 && towards === 'next')) {
  803. towards = null;
  804. }
  805. }
  806. if (this.$children.length < 2) {
  807. towards = null;
  808. }
  809. this.doAnimate(towards, {
  810. offsetLeft: offsetLeft,
  811. pageWidth: dragState.pageWidth,
  812. prevPage: dragState.prevPage,
  813. currentPage: dragState.dragPage,
  814. nextPage: dragState.nextPage,
  815. speedX: dragState.speedX
  816. });
  817. this.dragState = {};
  818. },
  819. initTimer: function initTimer() {
  820. var this$1 = this;
  821. if (this.auto > 0 && !this.timer) {
  822. this.timer = setInterval(function () {
  823. if (!this$1.continuous && (this$1.index >= this$1.pages.length - 1)) {
  824. return this$1.clearTimer();
  825. }
  826. if (!this$1.dragging && !this$1.animating) {
  827. this$1.next();
  828. }
  829. }, this.auto);
  830. }
  831. },
  832. clearTimer: function clearTimer() {
  833. clearInterval(this.timer);
  834. this.timer = null;
  835. }
  836. },
  837. destroyed: function destroyed() {
  838. if (this.timer) {
  839. this.clearTimer();
  840. }
  841. if (this.reInitTimer) {
  842. clearTimeout(this.reInitTimer);
  843. this.reInitTimer = null;
  844. }
  845. },
  846. mounted: function mounted() {
  847. var this$1 = this;
  848. this.ready = true;
  849. this.initTimer();
  850. this.reInitPages();
  851. var element = this.$el;
  852. element.addEventListener('touchstart', function (event) {
  853. if (this$1.prevent) event.preventDefault();
  854. if (this$1.stopPropagation) event.stopPropagation();
  855. if (this$1.animating) return;
  856. this$1.dragging = true;
  857. this$1.userScrolling = false;
  858. this$1.doOnTouchStart(event);
  859. });
  860. element.addEventListener('touchmove', function (event) {
  861. if (!this$1.dragging) return;
  862. if (this$1.timer) this$1.clearTimer();
  863. this$1.doOnTouchMove(event);
  864. });
  865. element.addEventListener('touchend', function (event) {
  866. if (this$1.userScrolling) {
  867. this$1.dragging = false;
  868. this$1.dragState = {};
  869. return;
  870. }
  871. if (!this$1.dragging) return;
  872. this$1.initTimer();
  873. this$1.doOnTouchEnd(event);
  874. this$1.dragging = false;
  875. });
  876. }
  877. };
  878. /***/ },
  879. /***/ 99:
  880. /***/ function(module, exports) {
  881. // removed by extract-text-webpack-plugin
  882. /***/ }
  883. /******/ });