@wanjunshijie/vue-seamless-scroll 2.0.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,914 +1 @@
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["vue-seamless-scroll"] = factory();
8
- else
9
- root["vue-seamless-scroll"] = factory();
10
- })((typeof self !== 'undefined' ? self : this), function() {
11
- return /******/ (function() { // webpackBootstrap
12
- /******/ var __webpack_modules__ = ({
13
-
14
- /***/ 608:
15
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
16
-
17
- "use strict";
18
- __webpack_require__.r(__webpack_exports__);
19
- /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81);
20
- /* harmony import */ var _node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
21
- /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(645);
22
- /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
23
- // Imports
24
-
25
-
26
- var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_noSourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
27
- // Module
28
- ___CSS_LOADER_EXPORT___.push([module.id, ".seamless-list[data-v-44bde8d8]{touch-action:none}.seamless-list[data-v-44bde8d8],.seamless-list__body[data-v-44bde8d8]{overflow:hidden}.seamless-list__body.is-horizontal[data-v-44bde8d8]{display:inline-block;font-size:0}", ""]);
29
- // Exports
30
- /* harmony default export */ __webpack_exports__["default"] = (___CSS_LOADER_EXPORT___);
31
-
32
-
33
- /***/ }),
34
-
35
- /***/ 645:
36
- /***/ (function(module) {
37
-
38
- "use strict";
39
-
40
-
41
- /*
42
- MIT License http://www.opensource.org/licenses/mit-license.php
43
- Author Tobias Koppers @sokra
44
- */
45
- module.exports = function (cssWithMappingToString) {
46
- var list = [];
47
-
48
- // return the list of modules as css string
49
- list.toString = function toString() {
50
- return this.map(function (item) {
51
- var content = "";
52
- var needLayer = typeof item[5] !== "undefined";
53
- if (item[4]) {
54
- content += "@supports (".concat(item[4], ") {");
55
- }
56
- if (item[2]) {
57
- content += "@media ".concat(item[2], " {");
58
- }
59
- if (needLayer) {
60
- content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
61
- }
62
- content += cssWithMappingToString(item);
63
- if (needLayer) {
64
- content += "}";
65
- }
66
- if (item[2]) {
67
- content += "}";
68
- }
69
- if (item[4]) {
70
- content += "}";
71
- }
72
- return content;
73
- }).join("");
74
- };
75
-
76
- // import a list of modules into the list
77
- list.i = function i(modules, media, dedupe, supports, layer) {
78
- if (typeof modules === "string") {
79
- modules = [[null, modules, undefined]];
80
- }
81
- var alreadyImportedModules = {};
82
- if (dedupe) {
83
- for (var k = 0; k < this.length; k++) {
84
- var id = this[k][0];
85
- if (id != null) {
86
- alreadyImportedModules[id] = true;
87
- }
88
- }
89
- }
90
- for (var _k = 0; _k < modules.length; _k++) {
91
- var item = [].concat(modules[_k]);
92
- if (dedupe && alreadyImportedModules[item[0]]) {
93
- continue;
94
- }
95
- if (typeof layer !== "undefined") {
96
- if (typeof item[5] === "undefined") {
97
- item[5] = layer;
98
- } else {
99
- item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
100
- item[5] = layer;
101
- }
102
- }
103
- if (media) {
104
- if (!item[2]) {
105
- item[2] = media;
106
- } else {
107
- item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
108
- item[2] = media;
109
- }
110
- }
111
- if (supports) {
112
- if (!item[4]) {
113
- item[4] = "".concat(supports);
114
- } else {
115
- item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
116
- item[4] = supports;
117
- }
118
- }
119
- list.push(item);
120
- }
121
- };
122
- return list;
123
- };
124
-
125
- /***/ }),
126
-
127
- /***/ 81:
128
- /***/ (function(module) {
129
-
130
- "use strict";
131
-
132
-
133
- module.exports = function (i) {
134
- return i[1];
135
- };
136
-
137
- /***/ }),
138
-
139
- /***/ 450:
140
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
141
-
142
- // style-loader: Adds some css to the DOM by adding a <style> tag
143
-
144
- // load the styles
145
- var content = __webpack_require__(608);
146
- if(content.__esModule) content = content.default;
147
- if(typeof content === 'string') content = [[module.id, content, '']];
148
- if(content.locals) module.exports = content.locals;
149
- // add the styles to the DOM
150
- var add = (__webpack_require__(402)/* ["default"] */ .Z)
151
- var update = add("41adcc57", content, true, {"sourceMap":false,"shadowMode":false});
152
-
153
- /***/ }),
154
-
155
- /***/ 402:
156
- /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
157
-
158
- "use strict";
159
-
160
- // EXPORTS
161
- __webpack_require__.d(__webpack_exports__, {
162
- Z: function() { return /* binding */ addStylesClient; }
163
- });
164
-
165
- ;// CONCATENATED MODULE: ./node_modules/vue-style-loader/lib/listToStyles.js
166
- /**
167
- * Translates the list format produced by css-loader into something
168
- * easier to manipulate.
169
- */
170
- function listToStyles (parentId, list) {
171
- var styles = []
172
- var newStyles = {}
173
- for (var i = 0; i < list.length; i++) {
174
- var item = list[i]
175
- var id = item[0]
176
- var css = item[1]
177
- var media = item[2]
178
- var sourceMap = item[3]
179
- var part = {
180
- id: parentId + ':' + i,
181
- css: css,
182
- media: media,
183
- sourceMap: sourceMap
184
- }
185
- if (!newStyles[id]) {
186
- styles.push(newStyles[id] = { id: id, parts: [part] })
187
- } else {
188
- newStyles[id].parts.push(part)
189
- }
190
- }
191
- return styles
192
- }
193
-
194
- ;// CONCATENATED MODULE: ./node_modules/vue-style-loader/lib/addStylesClient.js
195
- /*
196
- MIT License http://www.opensource.org/licenses/mit-license.php
197
- Author Tobias Koppers @sokra
198
- Modified by Evan You @yyx990803
199
- */
200
-
201
-
202
-
203
- var hasDocument = typeof document !== 'undefined'
204
-
205
- if (typeof DEBUG !== 'undefined' && DEBUG) {
206
- if (!hasDocument) {
207
- throw new Error(
208
- 'vue-style-loader cannot be used in a non-browser environment. ' +
209
- "Use { target: 'node' } in your Webpack config to indicate a server-rendering environment."
210
- ) }
211
- }
212
-
213
- /*
214
- type StyleObject = {
215
- id: number;
216
- parts: Array<StyleObjectPart>
217
- }
218
-
219
- type StyleObjectPart = {
220
- css: string;
221
- media: string;
222
- sourceMap: ?string
223
- }
224
- */
225
-
226
- var stylesInDom = {/*
227
- [id: number]: {
228
- id: number,
229
- refs: number,
230
- parts: Array<(obj?: StyleObjectPart) => void>
231
- }
232
- */}
233
-
234
- var head = hasDocument && (document.head || document.getElementsByTagName('head')[0])
235
- var singletonElement = null
236
- var singletonCounter = 0
237
- var isProduction = false
238
- var noop = function () {}
239
- var options = null
240
- var ssrIdKey = 'data-vue-ssr-id'
241
-
242
- // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
243
- // tags it will allow on a page
244
- var isOldIE = typeof navigator !== 'undefined' && /msie [6-9]\b/.test(navigator.userAgent.toLowerCase())
245
-
246
- function addStylesClient (parentId, list, _isProduction, _options) {
247
- isProduction = _isProduction
248
-
249
- options = _options || {}
250
-
251
- var styles = listToStyles(parentId, list)
252
- addStylesToDom(styles)
253
-
254
- return function update (newList) {
255
- var mayRemove = []
256
- for (var i = 0; i < styles.length; i++) {
257
- var item = styles[i]
258
- var domStyle = stylesInDom[item.id]
259
- domStyle.refs--
260
- mayRemove.push(domStyle)
261
- }
262
- if (newList) {
263
- styles = listToStyles(parentId, newList)
264
- addStylesToDom(styles)
265
- } else {
266
- styles = []
267
- }
268
- for (var i = 0; i < mayRemove.length; i++) {
269
- var domStyle = mayRemove[i]
270
- if (domStyle.refs === 0) {
271
- for (var j = 0; j < domStyle.parts.length; j++) {
272
- domStyle.parts[j]()
273
- }
274
- delete stylesInDom[domStyle.id]
275
- }
276
- }
277
- }
278
- }
279
-
280
- function addStylesToDom (styles /* Array<StyleObject> */) {
281
- for (var i = 0; i < styles.length; i++) {
282
- var item = styles[i]
283
- var domStyle = stylesInDom[item.id]
284
- if (domStyle) {
285
- domStyle.refs++
286
- for (var j = 0; j < domStyle.parts.length; j++) {
287
- domStyle.parts[j](item.parts[j])
288
- }
289
- for (; j < item.parts.length; j++) {
290
- domStyle.parts.push(addStyle(item.parts[j]))
291
- }
292
- if (domStyle.parts.length > item.parts.length) {
293
- domStyle.parts.length = item.parts.length
294
- }
295
- } else {
296
- var parts = []
297
- for (var j = 0; j < item.parts.length; j++) {
298
- parts.push(addStyle(item.parts[j]))
299
- }
300
- stylesInDom[item.id] = { id: item.id, refs: 1, parts: parts }
301
- }
302
- }
303
- }
304
-
305
- function createStyleElement () {
306
- var styleElement = document.createElement('style')
307
- styleElement.type = 'text/css'
308
- head.appendChild(styleElement)
309
- return styleElement
310
- }
311
-
312
- function addStyle (obj /* StyleObjectPart */) {
313
- var update, remove
314
- var styleElement = document.querySelector('style[' + ssrIdKey + '~="' + obj.id + '"]')
315
-
316
- if (styleElement) {
317
- if (isProduction) {
318
- // has SSR styles and in production mode.
319
- // simply do nothing.
320
- return noop
321
- } else {
322
- // has SSR styles but in dev mode.
323
- // for some reason Chrome can't handle source map in server-rendered
324
- // style tags - source maps in <style> only works if the style tag is
325
- // created and inserted dynamically. So we remove the server rendered
326
- // styles and inject new ones.
327
- styleElement.parentNode.removeChild(styleElement)
328
- }
329
- }
330
-
331
- if (isOldIE) {
332
- // use singleton mode for IE9.
333
- var styleIndex = singletonCounter++
334
- styleElement = singletonElement || (singletonElement = createStyleElement())
335
- update = applyToSingletonTag.bind(null, styleElement, styleIndex, false)
336
- remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true)
337
- } else {
338
- // use multi-style-tag mode in all other cases
339
- styleElement = createStyleElement()
340
- update = applyToTag.bind(null, styleElement)
341
- remove = function () {
342
- styleElement.parentNode.removeChild(styleElement)
343
- }
344
- }
345
-
346
- update(obj)
347
-
348
- return function updateStyle (newObj /* StyleObjectPart */) {
349
- if (newObj) {
350
- if (newObj.css === obj.css &&
351
- newObj.media === obj.media &&
352
- newObj.sourceMap === obj.sourceMap) {
353
- return
354
- }
355
- update(obj = newObj)
356
- } else {
357
- remove()
358
- }
359
- }
360
- }
361
-
362
- var replaceText = (function () {
363
- var textStore = []
364
-
365
- return function (index, replacement) {
366
- textStore[index] = replacement
367
- return textStore.filter(Boolean).join('\n')
368
- }
369
- })()
370
-
371
- function applyToSingletonTag (styleElement, index, remove, obj) {
372
- var css = remove ? '' : obj.css
373
-
374
- if (styleElement.styleSheet) {
375
- styleElement.styleSheet.cssText = replaceText(index, css)
376
- } else {
377
- var cssNode = document.createTextNode(css)
378
- var childNodes = styleElement.childNodes
379
- if (childNodes[index]) styleElement.removeChild(childNodes[index])
380
- if (childNodes.length) {
381
- styleElement.insertBefore(cssNode, childNodes[index])
382
- } else {
383
- styleElement.appendChild(cssNode)
384
- }
385
- }
386
- }
387
-
388
- function applyToTag (styleElement, obj) {
389
- var css = obj.css
390
- var media = obj.media
391
- var sourceMap = obj.sourceMap
392
-
393
- if (media) {
394
- styleElement.setAttribute('media', media)
395
- }
396
- if (options.ssrId) {
397
- styleElement.setAttribute(ssrIdKey, obj.id)
398
- }
399
-
400
- if (sourceMap) {
401
- // https://developer.chrome.com/devtools/docs/javascript-debugging
402
- // this makes source maps inside style tags work properly in Chrome
403
- css += '\n/*# sourceURL=' + sourceMap.sources[0] + ' */'
404
- // http://stackoverflow.com/a/26603875
405
- css += '\n/*# sourceMappingURL=data:application/json;base64,' + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + ' */'
406
- }
407
-
408
- if (styleElement.styleSheet) {
409
- styleElement.styleSheet.cssText = css
410
- } else {
411
- while (styleElement.firstChild) {
412
- styleElement.removeChild(styleElement.firstChild)
413
- }
414
- styleElement.appendChild(document.createTextNode(css))
415
- }
416
- }
417
-
418
-
419
- /***/ })
420
-
421
- /******/ });
422
- /************************************************************************/
423
- /******/ // The module cache
424
- /******/ var __webpack_module_cache__ = {};
425
- /******/
426
- /******/ // The require function
427
- /******/ function __webpack_require__(moduleId) {
428
- /******/ // Check if module is in cache
429
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
430
- /******/ if (cachedModule !== undefined) {
431
- /******/ return cachedModule.exports;
432
- /******/ }
433
- /******/ // Create a new module (and put it into the cache)
434
- /******/ var module = __webpack_module_cache__[moduleId] = {
435
- /******/ id: moduleId,
436
- /******/ // no module.loaded needed
437
- /******/ exports: {}
438
- /******/ };
439
- /******/
440
- /******/ // Execute the module function
441
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
442
- /******/
443
- /******/ // Return the exports of the module
444
- /******/ return module.exports;
445
- /******/ }
446
- /******/
447
- /************************************************************************/
448
- /******/ /* webpack/runtime/compat get default export */
449
- /******/ !function() {
450
- /******/ // getDefaultExport function for compatibility with non-harmony modules
451
- /******/ __webpack_require__.n = function(module) {
452
- /******/ var getter = module && module.__esModule ?
453
- /******/ function() { return module['default']; } :
454
- /******/ function() { return module; };
455
- /******/ __webpack_require__.d(getter, { a: getter });
456
- /******/ return getter;
457
- /******/ };
458
- /******/ }();
459
- /******/
460
- /******/ /* webpack/runtime/define property getters */
461
- /******/ !function() {
462
- /******/ // define getter functions for harmony exports
463
- /******/ __webpack_require__.d = function(exports, definition) {
464
- /******/ for(var key in definition) {
465
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
466
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
467
- /******/ }
468
- /******/ }
469
- /******/ };
470
- /******/ }();
471
- /******/
472
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
473
- /******/ !function() {
474
- /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
475
- /******/ }();
476
- /******/
477
- /******/ /* webpack/runtime/make namespace object */
478
- /******/ !function() {
479
- /******/ // define __esModule on exports
480
- /******/ __webpack_require__.r = function(exports) {
481
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
482
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
483
- /******/ }
484
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
485
- /******/ };
486
- /******/ }();
487
- /******/
488
- /******/ /* webpack/runtime/publicPath */
489
- /******/ !function() {
490
- /******/ __webpack_require__.p = "";
491
- /******/ }();
492
- /******/
493
- /************************************************************************/
494
- var __webpack_exports__ = {};
495
- // This entry need to be wrapped in an IIFE because it need to be in strict mode.
496
- !function() {
497
- "use strict";
498
- // ESM COMPAT FLAG
499
- __webpack_require__.r(__webpack_exports__);
500
-
501
- // EXPORTS
502
- __webpack_require__.d(__webpack_exports__, {
503
- "default": function() { return /* binding */ entry_lib; }
504
- });
505
-
506
- ;// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
507
- /* eslint-disable no-var */
508
- // This file is imported into lib/wc client bundles.
509
-
510
- if (typeof window !== 'undefined') {
511
- var currentScript = window.document.currentScript
512
- if (false) { var getCurrentScript; }
513
-
514
- var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/)
515
- if (src) {
516
- __webpack_require__.p = src[1] // eslint-disable-line
517
- }
518
- }
519
-
520
- // Indicate to webpack that this file can be concatenated
521
- /* harmony default export */ var setPublicPath = (null);
522
-
523
- ;// CONCATENATED MODULE: ./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/babel-loader/lib/index.js!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/vue-seamless-scroll/index.vue?vue&type=template&id=44bde8d8&scoped=true
524
- var render = function render() {
525
- var _vm = this,
526
- _c = _vm._self._c;
527
- return _c('div', {
528
- ref: "scrollBody",
529
- staticClass: "seamless-list",
530
- on: {
531
- "mouseenter": _vm.onMouseenter,
532
- "mouseleave": _vm.onMouseleave,
533
- "wheel": _vm.onWheel,
534
- "touchstart": _vm.onTouchStart,
535
- "touchmove": _vm.onTouchMove,
536
- "touchend": _vm.onTouchEnd,
537
- "touchcancel": _vm.onTouchEnd
538
- }
539
- }, [_c('div', {
540
- ref: "listBody",
541
- staticClass: "seamless-list__body",
542
- class: {
543
- 'is-horizontal': _vm.isHorizontal
544
- },
545
- style: {
546
- transform: _vm.getScrollStyle()
547
- }
548
- }, [_vm._t("default")], 2), _vm.canScroll ? _c('div', {
549
- staticClass: "seamless-list__body",
550
- class: {
551
- 'is-horizontal': _vm.isHorizontal
552
- },
553
- style: {
554
- transform: _vm.getScrollStyle()
555
- }
556
- }, [_vm._t("default")], 2) : _vm._e()]);
557
- };
558
- var staticRenderFns = [];
559
-
560
- ;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-82.use[1]!./node_modules/babel-loader/lib/index.js!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/vue-seamless-scroll/index.vue?vue&type=script&lang=js
561
- /* harmony default export */ var vue_seamless_scrollvue_type_script_lang_js = ({
562
- name: 'VueSeamlessScroll',
563
- props: {
564
- // 滚动方向
565
- direction: {
566
- type: String,
567
- default: 'top'
568
- },
569
- // 滚动速度
570
- steep: {
571
- type: Number,
572
- default: 0.5
573
- },
574
- // 是否可以滑轮滚动
575
- roller: {
576
- type: Boolean,
577
- default: true
578
- },
579
- // 滑轮滚动的距离
580
- distance: {
581
- type: Number,
582
- default: 20
583
- },
584
- data: Array
585
- },
586
- data() {
587
- return {
588
- listWidth: 0,
589
- listHeight: 0,
590
- bodyWidth: 0,
591
- bodyHeight: 0,
592
- canScroll: false,
593
- isStop: false,
594
- scrollDistance: 0,
595
- animationFrame: null,
596
- touchStartX: 0,
597
- touchStartY: 0,
598
- touchStartDistance: 0
599
- };
600
- },
601
- computed: {
602
- isHorizontal() {
603
- return this.direction === 'left' || this.direction === 'right';
604
- }
605
- },
606
- watch: {
607
- data: {
608
- handler() {
609
- this.$nextTick(() => {
610
- this.initData();
611
- });
612
- },
613
- deep: true
614
- }
615
- },
616
- mounted() {
617
- this.$nextTick(() => {
618
- this.initData();
619
- });
620
- },
621
- destroyed() {
622
- this.stop();
623
- },
624
- methods: {
625
- initData() {
626
- this.stop();
627
- this.$nextTick(() => {
628
- this.listWidth = this.$refs.listBody ? this.$refs.listBody.clientWidth : 0;
629
- this.listHeight = this.$refs.listBody ? this.$refs.listBody.clientHeight : 0;
630
- this.bodyWidth = this.$refs.scrollBody ? this.$refs.scrollBody.clientWidth : 0;
631
- this.bodyHeight = this.$refs.scrollBody ? this.$refs.scrollBody.clientHeight : 0;
632
- this.scrollDistance = 0;
633
- this.start();
634
- });
635
- },
636
- start() {
637
- this.isStop = false;
638
- if (this.isHorizontal) {
639
- this.getCanScroll(this.listWidth, this.bodyWidth);
640
- } else {
641
- this.getCanScroll(this.listHeight, this.bodyHeight);
642
- }
643
- if (this.canScroll) {
644
- this.run();
645
- }
646
- },
647
- run() {
648
- let that = this;
649
- this.clearAnimation();
650
- if (this.steep == 0) {
651
- this.setScrollDistance();
652
- return;
653
- }
654
- this.animationFrame = window.requestAnimationFrame(() => {
655
- that.setScrollDistance();
656
- if (!that.isStop) {
657
- if (that.direction === 'top' || that.direction === 'left') {
658
- that.scrollDistance -= that.steep;
659
- } else if (that.direction === 'bottom' || that.direction === 'right') {
660
- that.scrollDistance += that.steep;
661
- }
662
- that.run();
663
- }
664
- });
665
- },
666
- stop() {
667
- this.isStop = true;
668
- this.clearAnimation();
669
- },
670
- getCanScroll(listSize, bodySize) {
671
- this.canScroll = listSize && bodySize && listSize > bodySize;
672
- },
673
- setScrollDistance() {
674
- if (this.isHorizontal) {
675
- this.getScrollDistance(this.listWidth, this.bodyWidth);
676
- } else {
677
- this.getScrollDistance(this.listHeight, this.bodyHeight);
678
- }
679
- },
680
- getScrollDistance(listSize, bodySize) {
681
- let scrollDistance = Math.abs(this.scrollDistance);
682
- if (this.scrollDistance < 0) {
683
- let size = 2 * listSize - bodySize;
684
- if (scrollDistance > size) {
685
- this.scrollDistance = -(listSize - bodySize);
686
- }
687
- } else {
688
- this.scrollDistance = -listSize;
689
- }
690
- },
691
- getScrollStyle() {
692
- let style = '';
693
- if (!this.isHorizontal) {
694
- style = `translate(0, ${this.scrollDistance}px)`;
695
- } else {
696
- style = `translate(${this.scrollDistance}px, 0)`;
697
- }
698
- return style;
699
- },
700
- clearAnimation() {
701
- if (this.animationFrame) {
702
- cancelAnimationFrame(this.animationFrame);
703
- this.animationFrame = null;
704
- }
705
- },
706
- onMouseenter() {
707
- this.stop();
708
- },
709
- onMouseleave() {
710
- this.start();
711
- },
712
- onWheel(e) {
713
- e.preventDefault();
714
- if (!this.canScroll || !this.roller) {
715
- return false;
716
- }
717
- let dis = e.deltaY;
718
- if (dis > 0) {
719
- this.scrollDistance -= this.distance;
720
- } else {
721
- this.scrollDistance += this.distance;
722
- }
723
- this.run();
724
- },
725
- onTouchStart(e) {
726
- this.stop();
727
- let touch = e.touches[0];
728
- if (!touch) {
729
- return;
730
- }
731
- this.touchStartX = touch.clientX;
732
- this.touchStartY = touch.clientY;
733
- this.touchStartDistance = this.scrollDistance;
734
- },
735
- onTouchMove(e) {
736
- e.preventDefault();
737
- if (!this.canScroll) {
738
- return false;
739
- }
740
- let touch = e.touches[0];
741
- if (!touch) {
742
- return false;
743
- }
744
- if (this.isHorizontal) {
745
- this.scrollDistance = this.touchStartDistance + touch.clientX - this.touchStartX;
746
- this.scrollDistance = Math.max(-(this.listWidth - this.bodyWidth), Math.min(0, this.scrollDistance));
747
- } else {
748
- this.scrollDistance = this.touchStartDistance + touch.clientY - this.touchStartY;
749
- this.scrollDistance = Math.max(-(this.listHeight - this.bodyHeight), Math.min(0, this.scrollDistance));
750
- }
751
- },
752
- onTouchEnd() {
753
- this.start();
754
- }
755
- }
756
- });
757
- ;// CONCATENATED MODULE: ./packages/vue-seamless-scroll/index.vue?vue&type=script&lang=js
758
- /* harmony default export */ var packages_vue_seamless_scrollvue_type_script_lang_js = (vue_seamless_scrollvue_type_script_lang_js);
759
- // EXTERNAL MODULE: ./node_modules/vue-style-loader/index.js??clonedRuleSet-54.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-54.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-54.use[2]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-54.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./packages/vue-seamless-scroll/index.vue?vue&type=style&index=0&id=44bde8d8&prod&scoped=true&lang=css
760
- var vue_seamless_scrollvue_type_style_index_0_id_44bde8d8_prod_scoped_true_lang_css = __webpack_require__(450);
761
- ;// CONCATENATED MODULE: ./packages/vue-seamless-scroll/index.vue?vue&type=style&index=0&id=44bde8d8&prod&scoped=true&lang=css
762
-
763
- ;// CONCATENATED MODULE: ./node_modules/@vue/vue-loader-v15/lib/runtime/componentNormalizer.js
764
- /* globals __VUE_SSR_CONTEXT__ */
765
-
766
- // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
767
- // This module is a runtime utility for cleaner component module output and will
768
- // be included in the final webpack user bundle.
769
-
770
- function normalizeComponent(
771
- scriptExports,
772
- render,
773
- staticRenderFns,
774
- functionalTemplate,
775
- injectStyles,
776
- scopeId,
777
- moduleIdentifier /* server only */,
778
- shadowMode /* vue-cli only */
779
- ) {
780
- // Vue.extend constructor export interop
781
- var options =
782
- typeof scriptExports === 'function' ? scriptExports.options : scriptExports
783
-
784
- // render functions
785
- if (render) {
786
- options.render = render
787
- options.staticRenderFns = staticRenderFns
788
- options._compiled = true
789
- }
790
-
791
- // functional template
792
- if (functionalTemplate) {
793
- options.functional = true
794
- }
795
-
796
- // scopedId
797
- if (scopeId) {
798
- options._scopeId = 'data-v-' + scopeId
799
- }
800
-
801
- var hook
802
- if (moduleIdentifier) {
803
- // server build
804
- hook = function (context) {
805
- // 2.3 injection
806
- context =
807
- context || // cached call
808
- (this.$vnode && this.$vnode.ssrContext) || // stateful
809
- (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
810
- // 2.2 with runInNewContext: true
811
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
812
- context = __VUE_SSR_CONTEXT__
813
- }
814
- // inject component styles
815
- if (injectStyles) {
816
- injectStyles.call(this, context)
817
- }
818
- // register component module identifier for async chunk inferrence
819
- if (context && context._registeredComponents) {
820
- context._registeredComponents.add(moduleIdentifier)
821
- }
822
- }
823
- // used by ssr in case component is cached and beforeCreate
824
- // never gets called
825
- options._ssrRegister = hook
826
- } else if (injectStyles) {
827
- hook = shadowMode
828
- ? function () {
829
- injectStyles.call(
830
- this,
831
- (options.functional ? this.parent : this).$root.$options.shadowRoot
832
- )
833
- }
834
- : injectStyles
835
- }
836
-
837
- if (hook) {
838
- if (options.functional) {
839
- // for template-only hot-reload because in that case the render fn doesn't
840
- // go through the normalizer
841
- options._injectStyles = hook
842
- // register for functional component in vue file
843
- var originalRender = options.render
844
- options.render = function renderWithStyleInjection(h, context) {
845
- hook.call(context)
846
- return originalRender(h, context)
847
- }
848
- } else {
849
- // inject component registration as beforeCreate hook
850
- var existing = options.beforeCreate
851
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
852
- }
853
- }
854
-
855
- return {
856
- exports: scriptExports,
857
- options: options
858
- }
859
- }
860
-
861
- ;// CONCATENATED MODULE: ./packages/vue-seamless-scroll/index.vue
862
-
863
-
864
-
865
- ;
866
-
867
-
868
- /* normalize component */
869
-
870
- var component = normalizeComponent(
871
- packages_vue_seamless_scrollvue_type_script_lang_js,
872
- render,
873
- staticRenderFns,
874
- false,
875
- null,
876
- "44bde8d8",
877
- null
878
-
879
- )
880
-
881
- /* harmony default export */ var vue_seamless_scroll = (component.exports);
882
- ;// CONCATENATED MODULE: ./packages/vue-seamless-scroll/index.js
883
-
884
- vue_seamless_scroll.install = function (Vue) {
885
- Vue.component(vue_seamless_scroll.name, vue_seamless_scroll);
886
- };
887
- /* harmony default export */ var packages_vue_seamless_scroll = (vue_seamless_scroll);
888
- ;// CONCATENATED MODULE: ./packages/index.js
889
-
890
- const components = [packages_vue_seamless_scroll];
891
- const install = function (Vue) {
892
- components.forEach(comp => {
893
- Vue.component(comp.name, comp);
894
- });
895
- };
896
- if (typeof window !== 'undefined' && window.Vue) {
897
- install(window.Vue);
898
- }
899
- /* harmony default export */ var packages_0 = ({
900
- install,
901
- VueSeamlessScroll: packages_vue_seamless_scroll
902
- });
903
- ;// CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js
904
-
905
-
906
- /* harmony default export */ var entry_lib = (packages_0);
907
-
908
-
909
- }();
910
- /******/ return __webpack_exports__;
911
- /******/ })()
912
- ;
913
- });
914
- //# sourceMappingURL=vue-seamless-scroll.umd.js.map
1
+ (function(i,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(i=typeof globalThis<"u"?globalThis:i||self,e(i["vue-seamless-scroll"]={},i.Vue))})(this,function(i,e){"use strict";const T={name:"VueSeamlessScroll"},W=e.defineComponent({...T,props:{direction:{default:"top"},steep:{default:.5},roller:{type:Boolean,default:!0},distance:{default:20},data:{}},setup(c){const l=c,t=e.reactive({listWidth:0,listHeight:0,bodyWidth:0,bodyHeight:0,canScroll:!1,isStop:!1,scrollDistance:0,animationFrame:null,touchStartX:0,touchStartY:0,touchStartDistance:0}),a=e.ref(),r=e.ref(),s=e.computed(()=>l.direction==="left"||l.direction==="right");e.watch(()=>l.data,()=>{e.nextTick(()=>{S()})}),e.onMounted(()=>{e.nextTick(()=>{S()})}),e.onUnmounted(()=>{u()});function S(){u(),e.nextTick(()=>{var n,o,f,h;t.listWidth=((n=r.value)==null?void 0:n.clientWidth)||0,t.listHeight=((o=r.value)==null?void 0:o.clientHeight)||0,t.bodyWidth=((f=a.value)==null?void 0:f.clientWidth)||0,t.bodyHeight=((h=a.value)==null?void 0:h.clientHeight)||0,t.scrollDistance=0,m()})}function m(){t.isStop=!1,s.value?y(t.listWidth,t.bodyWidth):y(t.listHeight,t.bodyHeight),t.canScroll&&p()}function p(){if(b(),l.steep==0){D();return}t.animationFrame=window.requestAnimationFrame(()=>{D(),t.isStop||(l.direction==="top"||l.direction==="left"?t.scrollDistance-=l.steep:(l.direction==="bottom"||l.direction==="right")&&(t.scrollDistance+=l.steep),p())})}function u(){t.isStop=!0,b()}function y(n,o){t.canScroll=n&&o?n>o:!1}function D(){s.value?_(t.listWidth,t.bodyWidth):_(t.listHeight,t.bodyHeight)}function _(n,o){let f=Math.abs(t.scrollDistance);if(t.scrollDistance<0){let h=2*n-o;f>h&&(t.scrollDistance=-(n-o))}else t.scrollDistance=-n}function g(){let n="";return s.value?n=`translate(${t.scrollDistance}px, 0)`:n=`translate(0, ${t.scrollDistance}px)`,n}function b(){t.animationFrame&&(cancelAnimationFrame(t.animationFrame),t.animationFrame=null)}function k(){u()}function x(){m()}function M(n){if(n.preventDefault(),!t.canScroll||!l.roller)return;n.deltaY>0?t.scrollDistance-=l.distance:t.scrollDistance+=l.distance,p()}function B(n){u();const o=n.touches[0];o&&(t.touchStartX=o.clientX,t.touchStartY=o.clientY,t.touchStartDistance=t.scrollDistance)}function F(n){if(n.preventDefault(),!t.canScroll)return;const o=n.touches[0];o&&(s.value?(t.scrollDistance=t.touchStartDistance+o.clientX-t.touchStartX,t.scrollDistance=Math.max(-(t.listWidth-t.bodyWidth),Math.min(0,t.scrollDistance))):(t.scrollDistance=t.touchStartDistance+o.clientY-t.touchStartY,t.scrollDistance=Math.max(-(t.listHeight-t.bodyHeight),Math.min(0,t.scrollDistance))))}function H(){m()}return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:"seamless-list",ref_key:"scrollBody",ref:a,onMouseenter:k,onMouseleave:x,onWheel:M,onTouchstart:B,onTouchmove:F,onTouchend:H,onTouchcancel:H},[e.createElementVNode("div",{class:e.normalizeClass(["seamless-list__body",{"is-horizontal":s.value}]),ref_key:"listBody",ref:r,style:e.normalizeStyle({transform:g()})},[e.renderSlot(n.$slots,"default",{},void 0,!0)],6),t.canScroll?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["seamless-list__body",{"is-horizontal":s.value}]),style:e.normalizeStyle({transform:g()})},[e.renderSlot(n.$slots,"default",{},void 0,!0)],6)):e.createCommentVNode("",!0)],544))}}),d=((c,l)=>{const t=c.__vccOpts||c;for(const[a,r]of l)t[a]=r;return t})(W,[["__scopeId","data-v-9dc5b214"]]);d.install=c=>(c.component(d.name,d),c),i.VueSeamlessScroll=d,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});