vue-seamless-scroll.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["vueSeamlessScroll"] = factory();
  8. else
  9. root["vueSeamlessScroll"] = factory();
  10. })(typeof self !== 'undefined' ? self : this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, {
  50. /******/ configurable: false,
  51. /******/ enumerable: true,
  52. /******/ get: getter
  53. /******/ });
  54. /******/ }
  55. /******/ };
  56. /******/
  57. /******/ // getDefaultExport function for compatibility with non-harmony modules
  58. /******/ __webpack_require__.n = function(module) {
  59. /******/ var getter = module && module.__esModule ?
  60. /******/ function getDefault() { return module['default']; } :
  61. /******/ function getModuleExports() { return module; };
  62. /******/ __webpack_require__.d(getter, 'a', getter);
  63. /******/ return getter;
  64. /******/ };
  65. /******/
  66. /******/ // Object.prototype.hasOwnProperty.call
  67. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  68. /******/
  69. /******/ // __webpack_public_path__
  70. /******/ __webpack_require__.p = "";
  71. /******/
  72. /******/ // Load entry module and return exports
  73. /******/ return __webpack_require__(__webpack_require__.s = 1);
  74. /******/ })
  75. /************************************************************************/
  76. /******/ ([
  77. /* 0 */
  78. /***/ (function(module, exports, __webpack_require__) {
  79. "use strict";
  80. Object.defineProperty(exports, "__esModule", {
  81. value: true
  82. });
  83. __webpack_require__(4)();
  84. var arrayEqual = __webpack_require__(5);
  85. var copyObj = __webpack_require__(6);
  86. exports.default = {
  87. name: 'vue-seamless-scroll',
  88. data: function data() {
  89. return {
  90. xPos: 0,
  91. yPos: 0,
  92. delay: 0,
  93. copyHtml: '',
  94. height: 0,
  95. width: 0,
  96. realBoxWidth: 0 };
  97. },
  98. props: {
  99. data: {
  100. type: Array,
  101. default: function _default() {
  102. return [];
  103. }
  104. },
  105. classOption: {
  106. type: Object,
  107. default: function _default() {
  108. return {};
  109. }
  110. }
  111. },
  112. computed: {
  113. leftSwitchState: function leftSwitchState() {
  114. return this.xPos < 0;
  115. },
  116. rightSwitchState: function rightSwitchState() {
  117. return Math.abs(this.xPos) < this.realBoxWidth - this.width;
  118. },
  119. leftSwitchClass: function leftSwitchClass() {
  120. return this.leftSwitchState ? '' : this.options.switchDisabledClass;
  121. },
  122. rightSwitchClass: function rightSwitchClass() {
  123. return this.rightSwitchState ? '' : this.options.switchDisabledClass;
  124. },
  125. leftSwitch: function leftSwitch() {
  126. return {
  127. position: 'absolute',
  128. margin: this.height / 2 + 'px 0 0 -' + this.options.switchOffset + 'px',
  129. transform: 'translate(-100%,-50%)'
  130. };
  131. },
  132. rightSwitch: function rightSwitch() {
  133. return {
  134. position: 'absolute',
  135. margin: this.height / 2 + 'px 0 0 ' + (this.width + this.options.switchOffset) + 'px',
  136. transform: 'translateY(-50%)'
  137. };
  138. },
  139. float: function float() {
  140. return this.isHorizontal ? { float: 'left', overflow: 'hidden' } : { overflow: 'hidden' };
  141. },
  142. pos: function pos() {
  143. return {
  144. transform: 'translate(' + this.xPos + 'px,' + this.yPos + 'px)',
  145. transition: 'all ' + this.ease + ' ' + this.delay + 'ms',
  146. overflow: 'hidden'
  147. };
  148. },
  149. defaultOption: function defaultOption() {
  150. return {
  151. step: 1,
  152. limitMoveNum: 5,
  153. hoverStop: true,
  154. direction: 1,
  155. openTouch: true,
  156. singleHeight: 0,
  157. singleWidth: 0,
  158. waitTime: 1000,
  159. switchOffset: 30,
  160. autoPlay: true,
  161. navigation: false,
  162. switchSingleStep: 134,
  163. switchDelay: 400,
  164. switchDisabledClass: 'disabled',
  165. isSingleRemUnit: false };
  166. },
  167. options: function options() {
  168. return copyObj({}, this.defaultOption, this.classOption);
  169. },
  170. navigation: function navigation() {
  171. return this.options.navigation;
  172. },
  173. autoPlay: function autoPlay() {
  174. if (this.navigation) return false;
  175. return this.options.autoPlay;
  176. },
  177. scrollSwitch: function scrollSwitch() {
  178. return this.data.length >= this.options.limitMoveNum;
  179. },
  180. hoverStopSwitch: function hoverStopSwitch() {
  181. return this.options.hoverStop && this.autoPlay && this.scrollSwitch;
  182. },
  183. canTouchScroll: function canTouchScroll() {
  184. return this.options.openTouch;
  185. },
  186. isHorizontal: function isHorizontal() {
  187. return this.options.direction > 1;
  188. },
  189. baseFontSize: function baseFontSize() {
  190. return this.options.isSingleRemUnit ? parseInt(window.getComputedStyle(document.documentElement, null).fontSize) : 1;
  191. },
  192. realSingleStopWidth: function realSingleStopWidth() {
  193. return this.options.singleWidth * this.baseFontSize;
  194. },
  195. realSingleStopHeight: function realSingleStopHeight() {
  196. return this.options.singleHeight * this.baseFontSize;
  197. },
  198. step: function step() {
  199. var singleStep = void 0;
  200. var step = this.options.step;
  201. if (this.isHorizontal) {
  202. singleStep = this.realSingleStopWidth;
  203. } else {
  204. singleStep = this.realSingleStopHeight;
  205. }
  206. if (singleStep > 0 && singleStep % step > 0) {
  207. console.error('如果设置了单步滚动,step需是单步大小的约数,否则无法保证单步滚动结束的位置是否准确。~~~~~');
  208. }
  209. return step;
  210. }
  211. },
  212. methods: {
  213. reset: function reset() {
  214. this._cancle();
  215. this._initMove();
  216. },
  217. leftSwitchClick: function leftSwitchClick() {
  218. if (!this.leftSwitchState) return;
  219. if (Math.abs(this.xPos) < this.options.switchSingleStep) {
  220. this.xPos = 0;
  221. return;
  222. }
  223. this.xPos += this.options.switchSingleStep;
  224. },
  225. rightSwitchClick: function rightSwitchClick() {
  226. if (!this.rightSwitchState) return;
  227. if (this.realBoxWidth - this.width + this.xPos < this.options.switchSingleStep) {
  228. this.xPos = this.width - this.realBoxWidth;
  229. return;
  230. }
  231. this.xPos -= this.options.switchSingleStep;
  232. },
  233. _cancle: function _cancle() {
  234. cancelAnimationFrame(this.reqFrame || '');
  235. },
  236. touchStart: function touchStart(e) {
  237. var _this = this;
  238. if (!this.canTouchScroll) return;
  239. var timer = void 0;
  240. var touch = e.targetTouches[0];var _options = this.options,
  241. waitTime = _options.waitTime,
  242. singleHeight = _options.singleHeight,
  243. singleWidth = _options.singleWidth;
  244. this.startPos = {
  245. x: touch.pageX,
  246. y: touch.pageY
  247. };
  248. this.startPosY = this.yPos;
  249. this.startPosX = this.xPos;
  250. if (!!singleHeight && !!singleWidth) {
  251. if (timer) clearTimeout(timer);
  252. timer = setTimeout(function () {
  253. _this._cancle();
  254. }, waitTime + 20);
  255. } else {
  256. this._cancle();
  257. }
  258. },
  259. touchMove: function touchMove(e) {
  260. if (!this.canTouchScroll || e.targetTouches.length > 1 || e.scale && e.scale !== 1) return;
  261. var touch = e.targetTouches[0];
  262. var direction = this.options.direction;
  263. this.endPos = {
  264. x: touch.pageX - this.startPos.x,
  265. y: touch.pageY - this.startPos.y
  266. };
  267. event.preventDefault();
  268. var dir = Math.abs(this.endPos.x) < Math.abs(this.endPos.y) ? 1 : 0;
  269. if (dir === 1 && direction < 2) {
  270. this.yPos = this.startPosY + this.endPos.y;
  271. } else if (dir === 0 && direction > 1) {
  272. this.xPos = this.startPosX + this.endPos.x;
  273. }
  274. },
  275. touchEnd: function touchEnd() {
  276. var _this2 = this;
  277. if (!this.canTouchScroll) return;
  278. var timer = void 0;
  279. var direction = this.options.direction;
  280. this.delay = 50;
  281. if (direction === 1) {
  282. if (this.yPos > 0) this.yPos = 0;
  283. } else if (direction === 0) {
  284. var h = this.realBoxHeight / 2 * -1;
  285. if (this.yPos < h) this.yPos = h;
  286. } else if (direction === 2) {
  287. if (this.xPos > 0) this.xPos = 0;
  288. } else if (direction === 3) {
  289. var w = this.realBoxWidth * -1;
  290. if (this.xPos < w) this.xPos = w;
  291. }
  292. if (timer) clearTimeout(timer);
  293. timer = setTimeout(function () {
  294. _this2.delay = 0;
  295. _this2._move();
  296. }, this.delay);
  297. },
  298. enter: function enter() {
  299. if (this.hoverStopSwitch) this._stopMove();
  300. },
  301. leave: function leave() {
  302. if (this.hoverStopSwitch) this._startMove();
  303. },
  304. _move: function _move() {
  305. if (this.isHover) return;
  306. this._cancle();
  307. this.reqFrame = requestAnimationFrame(function () {
  308. var _this3 = this;
  309. var h = this.realBoxHeight / 2;
  310. var w = this.realBoxWidth / 2;var _options2 = this.options,
  311. direction = _options2.direction,
  312. waitTime = _options2.waitTime;
  313. var step = this.step;
  314. if (direction === 1) {
  315. if (Math.abs(this.yPos) >= h) {
  316. this.$emit('ScrollEnd');
  317. this.yPos = 0;
  318. }
  319. this.yPos -= step;
  320. } else if (direction === 0) {
  321. if (this.yPos >= 0) {
  322. this.$emit('ScrollEnd');
  323. this.yPos = h * -1;
  324. }
  325. this.yPos += step;
  326. } else if (direction === 2) {
  327. if (Math.abs(this.xPos) >= w) {
  328. this.$emit('ScrollEnd');
  329. this.xPos = 0;
  330. }
  331. this.xPos -= step;
  332. } else if (direction === 3) {
  333. if (this.xPos >= 0) {
  334. this.$emit('ScrollEnd');
  335. this.xPos = w * -1;
  336. }
  337. this.xPos += step;
  338. }
  339. if (this.singleWaitTime) clearTimeout(this.singleWaitTime);
  340. if (!!this.realSingleStopHeight) {
  341. if (Math.abs(this.yPos) % this.realSingleStopHeight < step) {
  342. this.singleWaitTime = setTimeout(function () {
  343. _this3._move();
  344. }, waitTime);
  345. } else {
  346. this._move();
  347. }
  348. } else if (!!this.realSingleStopWidth) {
  349. if (Math.abs(this.xPos) % this.realSingleStopWidth < step) {
  350. this.singleWaitTime = setTimeout(function () {
  351. _this3._move();
  352. }, waitTime);
  353. } else {
  354. this._move();
  355. }
  356. } else {
  357. this._move();
  358. }
  359. }.bind(this));
  360. },
  361. _initMove: function _initMove() {
  362. var _this4 = this;
  363. this.$nextTick(function () {
  364. var switchDelay = _this4.options.switchDelay;
  365. var autoPlay = _this4.autoPlay,
  366. isHorizontal = _this4.isHorizontal;
  367. _this4._dataWarm(_this4.data);
  368. _this4.copyHtml = '';
  369. if (isHorizontal) {
  370. _this4.height = _this4.$refs.wrap.offsetHeight;
  371. _this4.width = _this4.$refs.wrap.offsetWidth;
  372. var slotListWidth = _this4.$refs.slotList.offsetWidth;
  373. if (autoPlay) {
  374. slotListWidth = slotListWidth * 2 + 1;
  375. }
  376. _this4.$refs.realBox.style.width = slotListWidth + 'px';
  377. _this4.realBoxWidth = slotListWidth;
  378. }
  379. if (autoPlay) {
  380. _this4.ease = 'ease-in';
  381. _this4.delay = 0;
  382. } else {
  383. _this4.ease = 'linear';
  384. _this4.delay = switchDelay;
  385. return;
  386. }
  387. if (_this4.scrollSwitch) {
  388. var timer = void 0;
  389. if (timer) clearTimeout(timer);
  390. _this4.copyHtml = _this4.$refs.slotList.innerHTML;
  391. setTimeout(function () {
  392. _this4.realBoxHeight = _this4.$refs.realBox.offsetHeight;
  393. _this4._move();
  394. }, 0);
  395. } else {
  396. _this4._cancle();
  397. _this4.yPos = _this4.xPos = 0;
  398. }
  399. });
  400. },
  401. _dataWarm: function _dataWarm(data) {
  402. if (data.length > 100) {
  403. console.warn('\u6570\u636E\u8FBE\u5230\u4E86' + data.length + '\u6761\u6709\u70B9\u591A\u54E6~,\u53EF\u80FD\u4F1A\u9020\u6210\u90E8\u5206\u8001\u65E7\u6D4F\u89C8\u5668\u5361\u987F\u3002');
  404. }
  405. },
  406. _startMove: function _startMove() {
  407. this.isHover = false;
  408. this._move();
  409. },
  410. _stopMove: function _stopMove() {
  411. this.isHover = true;
  412. if (this.singleWaitTime) clearTimeout(this.singleWaitTime);
  413. this._cancle();
  414. }
  415. },
  416. mounted: function mounted() {
  417. this._initMove();
  418. },
  419. watch: {
  420. data: function data(newData, oldData) {
  421. this._dataWarm(newData);
  422. if (!arrayEqual(newData, oldData)) {
  423. this.reset();
  424. }
  425. },
  426. autoPlay: function autoPlay(bol) {
  427. if (bol) {
  428. this.reset();
  429. } else {
  430. this._stopMove();
  431. }
  432. }
  433. },
  434. beforeCreate: function beforeCreate() {
  435. this.reqFrame = null;
  436. this.singleWaitTime = null;
  437. this.isHover = false;
  438. this.ease = 'ease-in';
  439. },
  440. beforeDestroy: function beforeDestroy() {
  441. this._cancle();
  442. clearTimeout(this.singleWaitTime);
  443. }
  444. };
  445. /***/ }),
  446. /* 1 */
  447. /***/ (function(module, exports, __webpack_require__) {
  448. "use strict";
  449. Object.defineProperty(exports, "__esModule", {
  450. value: true
  451. });
  452. var _myClass = __webpack_require__(2);
  453. var _myClass2 = _interopRequireDefault(_myClass);
  454. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  455. _myClass2.default.install = function (Vue) {
  456. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  457. Vue.component(options.componentName || _myClass2.default.name, _myClass2.default);
  458. };
  459. if (typeof window !== 'undefined' && window.Vue) {
  460. Vue.component(_myClass2.default.name, _myClass2.default);
  461. }
  462. exports.default = _myClass2.default;
  463. /***/ }),
  464. /* 2 */
  465. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  466. "use strict";
  467. Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
  468. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_myClass_vue__ = __webpack_require__(0);
  469. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_myClass_vue___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_myClass_vue__);
  470. /* harmony namespace reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_myClass_vue__) if(__WEBPACK_IMPORT_KEY__ !== 'default') (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_myClass_vue__[key]; }) }(__WEBPACK_IMPORT_KEY__));
  471. /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_f52f2968_hasScoped_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_myClass_vue__ = __webpack_require__(7);
  472. var disposed = false
  473. var normalizeComponent = __webpack_require__(3)
  474. /* script */
  475. /* template */
  476. /* template functional */
  477. var __vue_template_functional__ = false
  478. /* styles */
  479. var __vue_styles__ = null
  480. /* scopeId */
  481. var __vue_scopeId__ = null
  482. /* moduleIdentifier (server only) */
  483. var __vue_module_identifier__ = null
  484. var Component = normalizeComponent(
  485. __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_myClass_vue___default.a,
  486. __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_f52f2968_hasScoped_false_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_myClass_vue__["a" /* default */],
  487. __vue_template_functional__,
  488. __vue_styles__,
  489. __vue_scopeId__,
  490. __vue_module_identifier__
  491. )
  492. Component.options.__file = "src/components/myClass.vue"
  493. /* hot reload */
  494. if (false) {(function () {
  495. var hotAPI = require("vue-hot-reload-api")
  496. hotAPI.install(require("vue"), false)
  497. if (!hotAPI.compatible) return
  498. module.hot.accept()
  499. if (!module.hot.data) {
  500. hotAPI.createRecord("data-v-f52f2968", Component.options)
  501. } else {
  502. hotAPI.reload("data-v-f52f2968", Component.options)
  503. }
  504. module.hot.dispose(function (data) {
  505. disposed = true
  506. })
  507. })()}
  508. /* harmony default export */ __webpack_exports__["default"] = (Component.exports);
  509. /***/ }),
  510. /* 3 */
  511. /***/ (function(module, exports) {
  512. /* globals __VUE_SSR_CONTEXT__ */
  513. // IMPORTANT: Do NOT use ES2015 features in this file.
  514. // This module is a runtime utility for cleaner component module output and will
  515. // be included in the final webpack user bundle.
  516. module.exports = function normalizeComponent (
  517. rawScriptExports,
  518. compiledTemplate,
  519. functionalTemplate,
  520. injectStyles,
  521. scopeId,
  522. moduleIdentifier /* server only */
  523. ) {
  524. var esModule
  525. var scriptExports = rawScriptExports = rawScriptExports || {}
  526. // ES6 modules interop
  527. var type = typeof rawScriptExports.default
  528. if (type === 'object' || type === 'function') {
  529. esModule = rawScriptExports
  530. scriptExports = rawScriptExports.default
  531. }
  532. // Vue.extend constructor export interop
  533. var options = typeof scriptExports === 'function'
  534. ? scriptExports.options
  535. : scriptExports
  536. // render functions
  537. if (compiledTemplate) {
  538. options.render = compiledTemplate.render
  539. options.staticRenderFns = compiledTemplate.staticRenderFns
  540. options._compiled = true
  541. }
  542. // functional template
  543. if (functionalTemplate) {
  544. options.functional = true
  545. }
  546. // scopedId
  547. if (scopeId) {
  548. options._scopeId = scopeId
  549. }
  550. var hook
  551. if (moduleIdentifier) { // server build
  552. hook = function (context) {
  553. // 2.3 injection
  554. context =
  555. context || // cached call
  556. (this.$vnode && this.$vnode.ssrContext) || // stateful
  557. (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
  558. // 2.2 with runInNewContext: true
  559. if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
  560. context = __VUE_SSR_CONTEXT__
  561. }
  562. // inject component styles
  563. if (injectStyles) {
  564. injectStyles.call(this, context)
  565. }
  566. // register component module identifier for async chunk inferrence
  567. if (context && context._registeredComponents) {
  568. context._registeredComponents.add(moduleIdentifier)
  569. }
  570. }
  571. // used by ssr in case component is cached and beforeCreate
  572. // never gets called
  573. options._ssrRegister = hook
  574. } else if (injectStyles) {
  575. hook = injectStyles
  576. }
  577. if (hook) {
  578. var functional = options.functional
  579. var existing = functional
  580. ? options.render
  581. : options.beforeCreate
  582. if (!functional) {
  583. // inject component registration as beforeCreate hook
  584. options.beforeCreate = existing
  585. ? [].concat(existing, hook)
  586. : [hook]
  587. } else {
  588. // for template-only hot-reload because in that case the render fn doesn't
  589. // go through the normalizer
  590. options._injectStyles = hook
  591. // register for functioal component in vue file
  592. options.render = function renderWithStyleInjection (h, context) {
  593. hook.call(context)
  594. return existing(h, context)
  595. }
  596. }
  597. }
  598. return {
  599. esModule: esModule,
  600. exports: scriptExports,
  601. options: options
  602. }
  603. }
  604. /***/ }),
  605. /* 4 */
  606. /***/ (function(module, exports) {
  607. /**
  608. * @desc AnimationFrame简单兼容hack
  609. */
  610. var animationFrame = function animationFrame() {
  611. window.cancelAnimationFrame = function () {
  612. return window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame || function (id) {
  613. return window.clearTimeout(id);
  614. };
  615. }();
  616. window.requestAnimationFrame = function () {
  617. return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) {
  618. return window.setTimeout(callback, 1000 / 60);
  619. };
  620. }();
  621. };
  622. module.exports = animationFrame;
  623. /***/ }),
  624. /* 5 */
  625. /***/ (function(module, exports) {
  626. /**
  627. * @desc 判断数组是否相等
  628. * @param {arr1,arr2}
  629. * @return {Boolean}
  630. */
  631. var arrayEqual = function arrayEqual(arr1, arr2) {
  632. if (arr1 === arr2) return true;
  633. if (arr1.length !== arr2.length) return false;
  634. for (var i = 0; i < arr1.length; ++i) {
  635. if (arr1[i] !== arr2[i]) return false;
  636. }
  637. return true;
  638. };
  639. module.exports = arrayEqual;
  640. /***/ }),
  641. /* 6 */
  642. /***/ (function(module, exports) {
  643. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  644. /**
  645. * @desc 深浅合并拷贝
  646. */
  647. function copyObj() {
  648. if (!Array.isArray) {
  649. Array.isArray = function (arg) {
  650. return Object.prototype.toString.call(arg) === '[object Array]';
  651. };
  652. }
  653. var name = void 0,
  654. options = void 0,
  655. src = void 0,
  656. copy = void 0,
  657. copyIsArray = void 0,
  658. clone = void 0,
  659. i = 1,
  660. target = arguments[0] || {},
  661. // 使用||运算符,排除隐式强制类型转换为false的数据类型
  662. deep = false,
  663. len = arguments.length;
  664. if (typeof target === 'boolean') {
  665. deep = target;
  666. target = arguments[1] || {};
  667. i++;
  668. }
  669. if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) !== 'object' && typeof target !== 'function') {
  670. target = {};
  671. }
  672. // 如果arguments.length === 1 或typeof arguments[0] === 'boolean',且存在arguments[1],则直接返回target对象
  673. if (i === len) {
  674. return target;
  675. }
  676. for (; i < len; i++) {
  677. //所以如果源对象中数据类型为Undefined或Null那么就会跳过本次循环,接着循环下一个源对象
  678. if ((options = arguments[i]) != null) {
  679. // 如果遇到源对象的数据类型为Boolean, Number for in循环会被跳过,不执行for in循环// src用于判断target对象是否存在name属性
  680. for (name in options) {
  681. // src用于判断target对象是否存在name属性
  682. src = target[name];
  683. // 需要复制的属性当前源对象的name属性
  684. copy = options[name];
  685. // 判断copy是否是数组
  686. copyIsArray = Array.isArray(copy);
  687. // 如果是深复制且copy是一个对象或数组则需要递归直到copy成为一个基本数据类型为止
  688. if (deep && copy && ((typeof copy === 'undefined' ? 'undefined' : _typeof(copy)) === 'object' || copyIsArray)) {
  689. if (copyIsArray) {
  690. copyIsArray = false;
  691. // 如果目标对象存在name属性且是一个数组
  692. // 则使用目标对象的name属性,否则重新创建一个数组,用于复制
  693. clone = src && Array.isArray(src) ? src : [];
  694. } else {
  695. // 如果目标对象存在name属性且是一个对象则使用目标对象的name属性,否则重新创建一个对象,用于复制
  696. clone = src && (typeof src === 'undefined' ? 'undefined' : _typeof(src)) === 'object' ? src : {};
  697. }
  698. // 深复制,所以递归调用copyObject函数
  699. // 返回值为target对象,即clone对象
  700. // copy是一个源对象
  701. target[name] = copyObj(deep, clone, copy);
  702. } else if (copy !== undefined) {
  703. // 浅复制,直接复制到target对象上
  704. target[name] = copy;
  705. }
  706. }
  707. }
  708. }
  709. return target;
  710. }
  711. module.exports = copyObj;
  712. /***/ }),
  713. /* 7 */
  714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  715. "use strict";
  716. var render = function() {
  717. var _vm = this
  718. var _h = _vm.$createElement
  719. var _c = _vm._self._c || _h
  720. return _c("div", { ref: "wrap" }, [
  721. _vm.navigation
  722. ? _c(
  723. "div",
  724. {
  725. class: _vm.leftSwitchClass,
  726. style: _vm.leftSwitch,
  727. on: { click: _vm.leftSwitchClick }
  728. },
  729. [_vm._t("left-switch")],
  730. 2
  731. )
  732. : _vm._e(),
  733. _vm._v(" "),
  734. _vm.navigation
  735. ? _c(
  736. "div",
  737. {
  738. class: _vm.rightSwitchClass,
  739. style: _vm.rightSwitch,
  740. on: { click: _vm.rightSwitchClick }
  741. },
  742. [_vm._t("right-switch")],
  743. 2
  744. )
  745. : _vm._e(),
  746. _vm._v(" "),
  747. _c(
  748. "div",
  749. {
  750. ref: "realBox",
  751. style: _vm.pos,
  752. on: {
  753. mouseenter: _vm.enter,
  754. mouseleave: _vm.leave,
  755. touchstart: _vm.touchStart,
  756. touchmove: _vm.touchMove,
  757. touchend: _vm.touchEnd
  758. }
  759. },
  760. [
  761. _c(
  762. "div",
  763. { ref: "slotList", style: _vm.float },
  764. [_vm._t("default")],
  765. 2
  766. ),
  767. _vm._v(" "),
  768. _c("div", {
  769. style: _vm.float,
  770. domProps: { innerHTML: _vm._s(_vm.copyHtml) }
  771. })
  772. ]
  773. )
  774. ])
  775. }
  776. var staticRenderFns = []
  777. render._withStripped = true
  778. var esExports = { render: render, staticRenderFns: staticRenderFns }
  779. /* harmony default export */ __webpack_exports__["a"] = (esExports);
  780. if (false) {
  781. module.hot.accept()
  782. if (module.hot.data) {
  783. require("vue-hot-reload-api") .rerender("data-v-f52f2968", esExports)
  784. }
  785. }
  786. /***/ })
  787. /******/ ])["default"];
  788. });