index.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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 = 238);
  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. /***/ 105:
  146. /***/ function(module, exports) {
  147. // removed by extract-text-webpack-plugin
  148. /***/ },
  149. /***/ 161:
  150. /***/ function(module, exports, __webpack_require__) {
  151. function injectStyle (ssrContext) {
  152. __webpack_require__(105)
  153. }
  154. var Component = __webpack_require__(0)(
  155. /* script */
  156. __webpack_require__(83),
  157. /* template */
  158. __webpack_require__(174),
  159. /* styles */
  160. injectStyle,
  161. /* scopeId */
  162. null,
  163. /* moduleIdentifier (server only) */
  164. null
  165. )
  166. module.exports = Component.exports
  167. /***/ },
  168. /***/ 174:
  169. /***/ function(module, exports) {
  170. module.exports={render:function (){var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;
  171. return _c('div', {
  172. staticClass: "mint-tab-container",
  173. on: {
  174. "touchstart": _vm.startDrag,
  175. "mousedown": _vm.startDrag,
  176. "touchmove": _vm.onDrag,
  177. "mousemove": _vm.onDrag,
  178. "mouseup": _vm.endDrag,
  179. "touchend": _vm.endDrag
  180. }
  181. }, [_c('div', {
  182. ref: "wrap",
  183. staticClass: "mint-tab-container-wrap"
  184. }, [_vm._t("default")], 2)])
  185. },staticRenderFns: []}
  186. /***/ },
  187. /***/ 2:
  188. /***/ function(module, exports, __webpack_require__) {
  189. "use strict";
  190. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue__ = __webpack_require__(1);
  191. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_vue__);
  192. /* unused harmony export on */
  193. /* unused harmony export off */
  194. /* harmony export (binding) */ __webpack_require__.d(exports, "c", function() { return once; });
  195. /* unused harmony export hasClass */
  196. /* harmony export (immutable) */ exports["a"] = addClass;
  197. /* harmony export (immutable) */ exports["b"] = removeClass;
  198. /* unused harmony export getStyle */
  199. /* unused harmony export setStyle */
  200. /* istanbul ignore next */
  201. var isServer = __WEBPACK_IMPORTED_MODULE_0_vue___default.a.prototype.$isServer;
  202. var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
  203. var MOZ_HACK_REGEXP = /^moz([A-Z])/;
  204. var ieVersion = isServer ? 0 : Number(document.documentMode);
  205. /* istanbul ignore next */
  206. var trim = function(string) {
  207. return (string || '').replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g, '');
  208. };
  209. /* istanbul ignore next */
  210. var camelCase = function(name) {
  211. return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
  212. return offset ? letter.toUpperCase() : letter;
  213. }).replace(MOZ_HACK_REGEXP, 'Moz$1');
  214. };
  215. /* istanbul ignore next */
  216. var on = (function() {
  217. if (!isServer && document.addEventListener) {
  218. return function(element, event, handler) {
  219. if (element && event && handler) {
  220. element.addEventListener(event, handler, false);
  221. }
  222. };
  223. } else {
  224. return function(element, event, handler) {
  225. if (element && event && handler) {
  226. element.attachEvent('on' + event, handler);
  227. }
  228. };
  229. }
  230. })();
  231. /* istanbul ignore next */
  232. var off = (function() {
  233. if (!isServer && document.removeEventListener) {
  234. return function(element, event, handler) {
  235. if (element && event) {
  236. element.removeEventListener(event, handler, false);
  237. }
  238. };
  239. } else {
  240. return function(element, event, handler) {
  241. if (element && event) {
  242. element.detachEvent('on' + event, handler);
  243. }
  244. };
  245. }
  246. })();
  247. /* istanbul ignore next */
  248. var once = function(el, event, fn) {
  249. var listener = function() {
  250. if (fn) {
  251. fn.apply(this, arguments);
  252. }
  253. off(el, event, listener);
  254. };
  255. on(el, event, listener);
  256. };
  257. /* istanbul ignore next */
  258. function hasClass(el, cls) {
  259. if (!el || !cls) return false;
  260. if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.');
  261. if (el.classList) {
  262. return el.classList.contains(cls);
  263. } else {
  264. return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1;
  265. }
  266. };
  267. /* istanbul ignore next */
  268. function addClass(el, cls) {
  269. if (!el) return;
  270. var curClass = el.className;
  271. var classes = (cls || '').split(' ');
  272. for (var i = 0, j = classes.length; i < j; i++) {
  273. var clsName = classes[i];
  274. if (!clsName) continue;
  275. if (el.classList) {
  276. el.classList.add(clsName);
  277. } else {
  278. if (!hasClass(el, clsName)) {
  279. curClass += ' ' + clsName;
  280. }
  281. }
  282. }
  283. if (!el.classList) {
  284. el.className = curClass;
  285. }
  286. };
  287. /* istanbul ignore next */
  288. function removeClass(el, cls) {
  289. if (!el || !cls) return;
  290. var classes = cls.split(' ');
  291. var curClass = ' ' + el.className + ' ';
  292. for (var i = 0, j = classes.length; i < j; i++) {
  293. var clsName = classes[i];
  294. if (!clsName) continue;
  295. if (el.classList) {
  296. el.classList.remove(clsName);
  297. } else {
  298. if (hasClass(el, clsName)) {
  299. curClass = curClass.replace(' ' + clsName + ' ', ' ');
  300. }
  301. }
  302. }
  303. if (!el.classList) {
  304. el.className = trim(curClass);
  305. }
  306. };
  307. /* istanbul ignore next */
  308. var getStyle = ieVersion < 9 ? function(element, styleName) {
  309. if (isServer) return;
  310. if (!element || !styleName) return null;
  311. styleName = camelCase(styleName);
  312. if (styleName === 'float') {
  313. styleName = 'styleFloat';
  314. }
  315. try {
  316. switch (styleName) {
  317. case 'opacity':
  318. try {
  319. return element.filters.item('alpha').opacity / 100;
  320. } catch (e) {
  321. return 1.0;
  322. }
  323. default:
  324. return (element.style[styleName] || element.currentStyle ? element.currentStyle[styleName] : null);
  325. }
  326. } catch (e) {
  327. return element.style[styleName];
  328. }
  329. } : function(element, styleName) {
  330. if (isServer) return;
  331. if (!element || !styleName) return null;
  332. styleName = camelCase(styleName);
  333. if (styleName === 'float') {
  334. styleName = 'cssFloat';
  335. }
  336. try {
  337. var computed = document.defaultView.getComputedStyle(element, '');
  338. return element.style[styleName] || computed ? computed[styleName] : null;
  339. } catch (e) {
  340. return element.style[styleName];
  341. }
  342. };
  343. /* istanbul ignore next */
  344. function setStyle(element, styleName, value) {
  345. if (!element || !styleName) return;
  346. if (typeof styleName === 'object') {
  347. for (var prop in styleName) {
  348. if (styleName.hasOwnProperty(prop)) {
  349. setStyle(element, prop, styleName[prop]);
  350. }
  351. }
  352. } else {
  353. styleName = camelCase(styleName);
  354. if (styleName === 'opacity' && ieVersion < 9) {
  355. element.style.filter = isNaN(value) ? '' : 'alpha(opacity=' + value * 100 + ')';
  356. } else {
  357. element.style[styleName] = value;
  358. }
  359. }
  360. };
  361. /***/ },
  362. /***/ 200:
  363. /***/ function(module, exports) {
  364. module.exports = require("array-find-index");
  365. /***/ },
  366. /***/ 238:
  367. /***/ function(module, exports, __webpack_require__) {
  368. module.exports = __webpack_require__(47);
  369. /***/ },
  370. /***/ 47:
  371. /***/ function(module, exports, __webpack_require__) {
  372. "use strict";
  373. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_tab_container_vue__ = __webpack_require__(161);
  374. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_tab_container_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__src_tab_container_vue__);
  375. Object.defineProperty(exports, "__esModule", { value: true });
  376. /* harmony reexport (default from non-hamory) */ __webpack_require__.d(exports, "default", function() { return __WEBPACK_IMPORTED_MODULE_0__src_tab_container_vue___default.a; });
  377. /***/ },
  378. /***/ 83:
  379. /***/ function(module, exports, __webpack_require__) {
  380. "use strict";
  381. Object.defineProperty(exports, "__esModule", { value: true });
  382. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__ = __webpack_require__(2);
  383. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_array_find_index__ = __webpack_require__(200);
  384. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_array_find_index___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_array_find_index__);
  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. * mt-tab-container
  421. * @desc 面板,搭配 tab-container-item 使用
  422. * @module components/tab-container
  423. *
  424. * @param {number|string} [value] - 当前激活的 tabId
  425. *
  426. * @example
  427. * <mt-tab-container v-model="selected">
  428. * <mt-tab-container-item id="1"> 内容A </mt-tab-container-item>
  429. * <mt-tab-container-item id="2"> 内容B </mt-tab-container-item>
  430. * <mt-tab-container-item id="3"> 内容C </mt-tab-container-item>
  431. * </mt-tab-container>
  432. */
  433. /* harmony default export */ exports["default"] = {
  434. name: 'mt-tab-container',
  435. props: {
  436. value: {},
  437. swipeable: Boolean
  438. },
  439. data: function data() {
  440. return {
  441. start: { x: 0, y: 0 },
  442. swiping: false,
  443. activeItems: [],
  444. pageWidth: 0,
  445. currentActive: this.value
  446. };
  447. },
  448. watch: {
  449. value: function value(val) {
  450. this.currentActive = val;
  451. },
  452. currentActive: function currentActive(val, oldValue) {
  453. this.$emit('input', val);
  454. if (!this.swipeable) return;
  455. var lastIndex = __WEBPACK_IMPORTED_MODULE_1_array_find_index___default()(this.$children,
  456. function (item) { return item.id === oldValue; });
  457. this.swipeLeaveTransition(lastIndex);
  458. }
  459. },
  460. mounted: function mounted() {
  461. if (!this.swipeable) return;
  462. this.wrap = this.$refs.wrap;
  463. this.pageWidth = this.wrap.clientWidth;
  464. this.limitWidth = this.pageWidth / 4;
  465. },
  466. methods: {
  467. swipeLeaveTransition: function swipeLeaveTransition(lastIndex) {
  468. var this$1 = this;
  469. if ( lastIndex === void 0 ) lastIndex = 0;
  470. if (typeof this.index !== 'number') {
  471. this.index = __WEBPACK_IMPORTED_MODULE_1_array_find_index___default()(this.$children,
  472. function (item) { return item.id === this$1.currentActive; });
  473. this.swipeMove(-lastIndex * this.pageWidth);
  474. }
  475. setTimeout(function () {
  476. this$1.wrap.classList.add('swipe-transition');
  477. this$1.swipeMove(-this$1.index * this$1.pageWidth);
  478. __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_mint_ui_src_utils_dom__["c" /* once */])(this$1.wrap, 'webkitTransitionEnd', function (_) {
  479. this$1.wrap.classList.remove('swipe-transition');
  480. this$1.wrap.style.webkitTransform = '';
  481. this$1.swiping = false;
  482. this$1.index = null;
  483. });
  484. }, 0);
  485. },
  486. swipeMove: function swipeMove(offset) {
  487. this.wrap.style.webkitTransform = "translate3d(" + offset + "px, 0, 0)";
  488. this.swiping = true;
  489. },
  490. startDrag: function startDrag(evt) {
  491. if (!this.swipeable) return;
  492. evt = evt.changedTouches ? evt.changedTouches[0] : evt;
  493. this.dragging = true;
  494. this.start.x = evt.pageX;
  495. this.start.y = evt.pageY;
  496. },
  497. onDrag: function onDrag(evt) {
  498. var this$1 = this;
  499. if (!this.dragging) return;
  500. var swiping;
  501. var e = evt.changedTouches ? evt.changedTouches[0] : evt;
  502. var offsetTop = e.pageY - this.start.y;
  503. var offsetLeft = e.pageX - this.start.x;
  504. var y = Math.abs(offsetTop);
  505. var x = Math.abs(offsetLeft);
  506. swiping = !(x < 5 || (x >= 5 && y >= x * 1.73));
  507. if (!swiping) return;
  508. evt.preventDefault();
  509. var len = this.$children.length - 1;
  510. var index = __WEBPACK_IMPORTED_MODULE_1_array_find_index___default()(this.$children,
  511. function (item) { return item.id === this$1.currentActive; });
  512. var currentPageOffset = index * this.pageWidth;
  513. var offset = offsetLeft - currentPageOffset;
  514. var absOffset = Math.abs(offset);
  515. if (absOffset > len * this.pageWidth ||
  516. (offset > 0 && offset < this.pageWidth)) {
  517. this.swiping = false;
  518. return;
  519. }
  520. this.offsetLeft = offsetLeft;
  521. this.index = index;
  522. this.swipeMove(offset);
  523. },
  524. endDrag: function endDrag() {
  525. if (!this.swiping) return;
  526. this.dragging = false;
  527. var direction = this.offsetLeft > 0 ? -1 : 1;
  528. var isChange = Math.abs(this.offsetLeft) > this.limitWidth;
  529. if (isChange) {
  530. this.index += direction;
  531. var child = this.$children[this.index];
  532. if (child) {
  533. this.currentActive = child.id;
  534. return;
  535. }
  536. }
  537. this.swipeLeaveTransition();
  538. }
  539. }
  540. };
  541. /***/ }
  542. /******/ });