UNPKG

vue3-seamless-scroll

Version:
1,049 lines (903 loc) 35.5 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("vue")); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["vue3SeamlessScroll"] = factory(require("vue")); else root["vue3SeamlessScroll"] = factory(root["Vue"]); })((typeof self !== 'undefined' ? self : this), function(__WEBPACK_EXTERNAL_MODULE__8bbf__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "fb15"); /******/ }) /************************************************************************/ /******/ ({ /***/ "38a8": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_v16_dist_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_v16_dist_index_js_ref_0_1_cssSeamlessScroll_vue_vue_type_style_index_0_id_72773174_lang_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("42e9"); /* harmony import */ var _node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_v16_dist_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_v16_dist_index_js_ref_0_1_cssSeamlessScroll_vue_vue_type_style_index_0_id_72773174_lang_css__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_mini_css_extract_plugin_dist_loader_js_ref_6_oneOf_1_0_node_modules_css_loader_dist_cjs_js_ref_6_oneOf_1_1_node_modules_vue_loader_v16_dist_stylePostLoader_js_node_modules_postcss_loader_src_index_js_ref_6_oneOf_1_2_node_modules_cache_loader_dist_cjs_js_ref_0_0_node_modules_vue_loader_v16_dist_index_js_ref_0_1_cssSeamlessScroll_vue_vue_type_style_index_0_id_72773174_lang_css__WEBPACK_IMPORTED_MODULE_0__); /* unused harmony reexport * */ /***/ }), /***/ "42e9": /***/ (function(module, exports, __webpack_require__) { // extracted by mini-css-extract-plugin /***/ }), /***/ "8875": /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// addapted from the document.currentScript polyfill by Adam Miller // MIT license // source: https://github.com/amiller-gh/currentScript-polyfill // added support for Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1620505 (function (root, factory) { if (true) { !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } else {} }(typeof self !== 'undefined' ? self : this, function () { function getCurrentScript () { var descriptor = Object.getOwnPropertyDescriptor(document, 'currentScript') // for chrome if (!descriptor && 'currentScript' in document && document.currentScript) { return document.currentScript } // for other browsers with native support for currentScript if (descriptor && descriptor.get !== getCurrentScript && document.currentScript) { return document.currentScript } // IE 8-10 support script readyState // IE 11+ & Firefox support stack trace try { throw new Error(); } catch (err) { // Find the second match for the "at" string to get file src url from stack. var ieStackRegExp = /.*at [^(]*\((.*):(.+):(.+)\)$/ig, ffStackRegExp = /@([^@]*):(\d+):(\d+)\s*$/ig, stackDetails = ieStackRegExp.exec(err.stack) || ffStackRegExp.exec(err.stack), scriptLocation = (stackDetails && stackDetails[1]) || false, line = (stackDetails && stackDetails[2]) || false, currentLocation = document.location.href.replace(document.location.hash, ''), pageSource, inlineScriptSourceRegExp, inlineScriptSource, scripts = document.getElementsByTagName('script'); // Live NodeList collection if (scriptLocation === currentLocation) { pageSource = document.documentElement.outerHTML; inlineScriptSourceRegExp = new RegExp('(?:[^\\n]+?\\n){0,' + (line - 2) + '}[^<]*<script>([\\d\\D]*?)<\\/script>[\\d\\D]*', 'i'); inlineScriptSource = pageSource.replace(inlineScriptSourceRegExp, '$1').trim(); } for (var i = 0; i < scripts.length; i++) { // If ready state is interactive, return the script tag if (scripts[i].readyState === 'interactive') { return scripts[i]; } // If src matches, return the script tag if (scripts[i].src === scriptLocation) { return scripts[i]; } // If inline source matches, return the script tag if ( scriptLocation === currentLocation && scripts[i].innerHTML && scripts[i].innerHTML.trim() === inlineScriptSource ) { return scripts[i]; } } // If no match, return null return null; } }; return getCurrentScript })); /***/ }), /***/ "8bbf": /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE__8bbf__; /***/ }), /***/ "fb15": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // EXPORTS __webpack_require__.d(__webpack_exports__, "jsSeamlessScroll", function() { return /* reexport */ components_jsSeamlessScroll; }); __webpack_require__.d(__webpack_exports__, "cssSeamlessScroll", function() { return /* reexport */ components_cssSeamlessScroll; }); // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js // This file is imported into lib/wc client bundles. if (typeof window !== 'undefined') { var currentScript = window.document.currentScript if (true) { var getCurrentScript = __webpack_require__("8875") currentScript = getCurrentScript() // for backward compatibility, because previously we directly included the polyfill if (!('currentScript' in document)) { Object.defineProperty(document, 'currentScript', { get: getCurrentScript }) } } var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/) if (src) { __webpack_require__.p = src[1] // eslint-disable-line } } // Indicate to webpack that this file can be concatenated /* harmony default export */ var setPublicPath = (null); // EXTERNAL MODULE: external {"commonjs":"vue","commonjs2":"vue","root":"Vue"} var external_commonjs_vue_commonjs2_vue_root_Vue_ = __webpack_require__("8bbf"); // CONCATENATED MODULE: ./node_modules/vue-loader-v16/dist/templateLoader.js??ref--5!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./package/components/jsSeamlessScroll/jsSeamlessScroll.vue?vue&type=template&id=7f4bdcd5 const _hoisted_1 = { ref: "scrollRef" } function render(_ctx, _cache, $props, $setup, $data, $options) { return (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("div", _hoisted_1, [ Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])("div", { ref: "realBoxRef", style: _ctx.realBoxStyle, onMouseenter: _cache[1] || (_cache[1] = (...args) => (_ctx.enter(...args))), onMouseleave: _cache[2] || (_cache[2] = (...args) => (_ctx.leave(...args))) }, [ Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])("div", { ref: "slotListRef", style: _ctx.floatStyle }, [ Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "default") ], 4), (_ctx.slotHtml && _ctx.isScroll) ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("div", { key: 0, style: _ctx.floatStyle }, [ Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "html") ], 4)) : (!_ctx.slotHtml && _ctx.isScroll) ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("div", { key: 1, innerHTML: _ctx.scrollHtml, style: _ctx.floatStyle }, null, 12, ["innerHTML"])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true) ], 36) ], 512)) } // CONCATENATED MODULE: ./package/components/jsSeamlessScroll/jsSeamlessScroll.vue?vue&type=template&id=7f4bdcd5 // CONCATENATED MODULE: ./package/public.js window.cancelAnimationFrame = (function () { return ( window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame || function (id) { return window.clearTimeout(id); } ); })(); window.requestAnimationFrame = (function () { return ( window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback) { return window.setTimeout(callback, 1000 / 60); } ); })(); function dataWarm(datas) { if (datas.length > 100) { console.warn( `数据达到了${datas.length}条有点多哦~,可能会造成部分老旧浏览器卡顿。` ); } } function validator(value) { if (isNaN(value)) { console.warn("Must be in number format"); return "0"; } return value + ""; } // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./package/components/jsSeamlessScroll/jsSeamlessScroll.vue?vue&type=script&lang=js /* harmony default export */ var jsSeamlessScrollvue_type_script_lang_js = (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ name: "js-seamless-scroll", props: { datas: { type: Array, required: true, }, // 步进速度,step 需是单步大小的约数 step: { type: [Number, String], default: 1, validator: validator, }, // 开启滚动的数据量 limitScrollNum: { type: [Number, String], default: 5, validator: validator, }, // 是否开启鼠标悬停 hover: { type: Boolean, default: false, }, // 控制滚动方向 direction: { type: String, default: "up", }, // 单步运动停止的高度 singleHeight: { type: [Number, String], default: 0, validator: validator, }, // 单步运动停止的宽度 singleWidth: { type: [Number, String], default: 0, validator: validator, }, // 单步停止等待时间(默认值 1000ms) singleWaitTime: { type: [Number, String], default: 1000, validator: validator, }, // 是否开启自动滚动 autoPlay: { type: Boolean, default: true, }, // singleHeight and singleWidth 是否开启 rem 度量 isRemUnit: { type: Boolean, default: false, }, // 开启数据更新监听 isWatch: { type: Boolean, default: true, }, // 动画时间 delay: { type: [Number, String], default: 0, validator: validator, }, // 动画方式 ease: { type: String, default: "ease-in", }, }, setup(props, { slots }) { const scrollRef = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(null); const slotListRef = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(null); const realBoxRef = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(null); const slotHtml = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(slots.html != undefined); const scrollHtml = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(""); const state = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["reactive"])({ xPos: 0, yPos: 0, reqFrame: null, singleWaitTimeout: null, realBoxWidth: 0, realBoxHeight: 0, isHover: false, }); const realBoxStyle = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { return { width: state.realBoxWidth ? `${state.realBoxWidth}px` : "auto", transform: `translate(${state.xPos}px,${state.yPos}px)`, transition: `all ${props.ease} ${props.delay}ms`, overflow: "hidden", }; }); const isHorizontal = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])( () => props.direction == "left" || props.direction == "right" ); const floatStyle = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { return isHorizontal.value ? { float: "left", overflow: "hidden" } : { overflow: "hidden" }; }); const isScroll = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => props.datas.length >= props.limitScrollNum); const baseFontSize = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { return props.isRemUnit ? parseInt( window.getComputedStyle(document.documentElement, null).fontSize ) : 1; }); const realSingleStopWidth = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])( () => props.singleWidth * baseFontSize.value ); const realSingleStopHeight = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])( () => props.singleHeight * baseFontSize.value ); const hoverStop = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])( () => props.hover && props.autoPlay && isScroll.value ); const step = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { let singleStep; let _step = props.step; if (isHorizontal.value) { singleStep = realSingleStopWidth.value; } else { singleStep = realSingleStopHeight.value; } if (singleStep > 0 && singleStep % _step > 0) { console.error( "如果设置了单步滚动,step需是单步大小的约数,否则无法保证单步滚动结束的位置是否准确。~~~~~" ); } return _step; }); function cancle() { cancelAnimationFrame(state.reqFrame || ""); state.reqFrame = null; } function move() { if (state.isHover) { return; } cancle(); state.reqFrame = requestAnimationFrame(function () { const h = state.realBoxHeight / 2; const w = state.realBoxWidth / 2; let { direction, singleWaitTime } = props; if (direction === "up") { if (Math.abs(state.yPos) >= h) { state.yPos = 0; } state.yPos -= step.value; } else if (direction === "down") { if (state.yPos >= 0) { state.yPos = h * -1; } state.yPos += step.value; } else if (direction === "left") { if (Math.abs(state.xPos) >= w) { state.xPos = 0; } state.xPos -= step.value; } else if (direction === "right") { if (state.xPos >= 0) { state.xPos = w * -1; } state.xPos += step.value; } if (state.singleWaitTimeout) { clearTimeout(state.singleWaitTimeout); } if (!!realSingleStopHeight.value) { if (Math.abs(state.yPos) % realSingleStopHeight.value < step.value) { state.singleWaitTimeout = setTimeout(() => { move(); }, singleWaitTime); } else { move(); } } else if (!!realSingleStopWidth.value) { if (Math.abs(state.xPos) % realSingleStopWidth.value < step.value) { state.singleWaitTimeout = setTimeout(() => { move(); }, singleWaitTime); } else { move(); } } else { move(); } }); } function initMove() { Object(external_commonjs_vue_commonjs2_vue_root_Vue_["nextTick"])(() => { dataWarm(props.datas); scrollHtml.value = ""; if (isHorizontal.value) { let slotListWidth = slotListRef.value.offsetWidth; if (props.autoPlay) { slotListWidth = slotListWidth * 2 + 1; } state.realBoxWidth = slotListWidth; } if (props.autoPlay) { if (isScroll.value) { if (!slotHtml.value) { scrollHtml.value = slotListRef.value.innerHTML; Object(external_commonjs_vue_commonjs2_vue_root_Vue_["nextTick"])(() => { state.realBoxHeight = realBoxRef.value.offsetHeight; move(); }); } else { state.realBoxHeight = realBoxRef.value.offsetHeight; move(); } } else { cancle(); state.yPos = state.xPos = 0; } } }); } function startMove() { state.isHover = false; move(); } function stopMove() { state.isHover = true; if (state.singleWaitTimeout) { clearTimeout(state.singleWaitTimeout); } cancle(); } function enter() { if (hoverStop.value) { stopMove(); } } function leave() { if (hoverStop.value) { startMove(); } } function reset() { cancle(); state.isHover = false; initMove(); } Object(external_commonjs_vue_commonjs2_vue_root_Vue_["watch"])( () => props.datas, () => { if (props.isWatch) { reset(); } }, { deep: true, } ); Object(external_commonjs_vue_commonjs2_vue_root_Vue_["watch"])( () => props.autoPlay, (newValue) => { if (newValue) { reset(); } else { stopMove(); } } ); Object(external_commonjs_vue_commonjs2_vue_root_Vue_["onBeforeMount"])(() => { cancle(); clearTimeout(state.singleWaitTimeout); }); Object(external_commonjs_vue_commonjs2_vue_root_Vue_["onMounted"])(() => { initMove(); }); return { scrollRef, slotListRef, realBoxRef, realBoxStyle, floatStyle, isScroll, slotHtml, scrollHtml, enter, leave, }; }, })); // CONCATENATED MODULE: ./package/components/jsSeamlessScroll/jsSeamlessScroll.vue?vue&type=script&lang=js // CONCATENATED MODULE: ./package/components/jsSeamlessScroll/jsSeamlessScroll.vue jsSeamlessScrollvue_type_script_lang_js.render = render /* harmony default export */ var jsSeamlessScroll = (jsSeamlessScrollvue_type_script_lang_js); // CONCATENATED MODULE: ./package/components/jsSeamlessScroll/index.js jsSeamlessScroll.install = (app) => { app.component(jsSeamlessScroll.name, jsSeamlessScroll) }; /* harmony default export */ var components_jsSeamlessScroll = (jsSeamlessScroll); // CONCATENATED MODULE: ./node_modules/vue-loader-v16/dist/templateLoader.js??ref--5!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./package/components/cssSeamlessScroll/cssSeamlessScroll.vue?vue&type=template&id=72773174 const cssSeamlessScrollvue_type_template_id_72773174_hoisted_1 = { ref: "scrollRef" } function cssSeamlessScrollvue_type_template_id_72773174_render(_ctx, _cache, $props, $setup, $data, $options) { return (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("div", cssSeamlessScrollvue_type_template_id_72773174_hoisted_1, [ Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])("div", { ref: "realBoxRef", onMouseenter: _cache[1] || (_cache[1] = (...args) => (_ctx.enter(...args))), onMouseleave: _cache[2] || (_cache[2] = (...args) => (_ctx.leave(...args))), class: _ctx.cssStep ? 'step realBox' : 'realBox' }, [ Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createVNode"])("div", { ref: "slotListRef", style: _ctx.floatStyle }, [ Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "default") ], 4), (_ctx.slotHtml && _ctx.showHtml) ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("div", { key: 0, style: _ctx.floatStyle }, [ Object(external_commonjs_vue_commonjs2_vue_root_Vue_["renderSlot"])(_ctx.$slots, "html") ], 4)) : (!_ctx.slotHtml && _ctx.showHtml) ? (Object(external_commonjs_vue_commonjs2_vue_root_Vue_["openBlock"])(), Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createBlock"])("div", { key: 1, innerHTML: _ctx.scrollHtml, style: _ctx.floatStyle }, null, 12, ["innerHTML"])) : Object(external_commonjs_vue_commonjs2_vue_root_Vue_["createCommentVNode"])("", true) ], 34) ], 512)) } // CONCATENATED MODULE: ./package/components/cssSeamlessScroll/cssSeamlessScroll.vue?vue&type=template&id=72773174 // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader-v16/dist??ref--0-1!./package/components/cssSeamlessScroll/cssSeamlessScroll.vue?vue&type=script&lang=js const __default__ = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["defineComponent"])({ name: "css-seamless-scroll", props: { datas: { type: Array, required: true, }, // 步进速度,step 需是单步大小的约数 step: { type: [Number, String], validator: validator, }, // 开启滚动的数据量 limitScrollNum: { type: [Number, String], default: 5, validator: validator, }, // 是否开启鼠标悬停 hover: { type: Boolean, default: false, }, // 控制滚动方向 direction: { type: String, default: "up", }, // 是否开启自动滚动 autoPlay: { type: Boolean, default: true, }, // 开启数据更新监听 isWatch: { type: Boolean, default: true, }, // 动画循环次数 count: { type: [Number, String], default: "infinite", validator: function (value) { if (isNaN(value) && value !== "infinite") { console.warn("Must be in number format"); return "infinite"; } return value + ""; }, }, // 动画时间 duration: { type: [Number, String], validator: validator, }, // 贝塞尔曲线 cubicBezier: { type: Object, default: { x1: 0, y1: 0, x2: 1, y2: 1, }, }, }, setup(props, { slots }) { const scrollRef = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(null); const slotListRef = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(null); const realBoxRef = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(null); const slotHtml = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(slots.html != undefined); const scrollHtml = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(""); const cssPlayStatus = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])("paused"); const realBoxWidth = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(0); const realBoxHeight = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["ref"])(0); const isHorizontal = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])( () => props.direction == "left" || props.direction == "right" ); const floatStyle = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { return isHorizontal.value ? { float: "left", overflow: "hidden" } : { overflow: "hidden" }; }); const isScroll = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => props.datas.length >= props.limitScrollNum); const hoverStop = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])( () => props.hover && props.autoPlay && isScroll.value ); const showHtml = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => props.autoPlay && isScroll.value); function initMove() { Object(external_commonjs_vue_commonjs2_vue_root_Vue_["nextTick"])(() => { dataWarm(props.datas); scrollHtml.value = ""; if (isHorizontal.value) { let slotListWidth = slotListRef.value.offsetWidth; if (props.autoPlay) { slotListWidth = slotListWidth * 2 + 1; } realBoxWidth.value = slotListWidth; } if (props.autoPlay) { if (isScroll.value) { if (!slotHtml.value) { scrollHtml.value = slotListRef.value.innerHTML; Object(external_commonjs_vue_commonjs2_vue_root_Vue_["nextTick"])(() => { realBoxHeight.value = realBoxRef.value.offsetHeight; cssPlayStatus.value = "running"; }); } else { realBoxHeight.value = realBoxRef.value.offsetHeight; cssPlayStatus.value = "running"; } } } }); } function enter() { if (hoverStop.value) { cssPlayStatus.value = "paused"; } } function leave() { if (hoverStop.value) { cssPlayStatus.value = "running"; } } Object(external_commonjs_vue_commonjs2_vue_root_Vue_["watch"])( () => props.datas, () => { if (props.isWatch) { cssPlayStatus.value = "paused"; initMove(); } }, { deep: true, } ); Object(external_commonjs_vue_commonjs2_vue_root_Vue_["watch"])( () => props.autoPlay, (newValue) => { if (newValue) { cssPlayStatus.value = "running"; } else { cssPlayStatus.value = "paused"; } } ); Object(external_commonjs_vue_commonjs2_vue_root_Vue_["onMounted"])(() => { initMove(); }); const cssDuration = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { if (props.duration !== undefined) { return `${props.duration}s`; } if (isHorizontal.value && realBoxWidth.value != 0) { return `${realBoxWidth.value / 2 / 60}s`; } if (realBoxHeight.value != 0) { return `${realBoxHeight.value / 2 / 60}s`; } return "0s"; }); const cssStep = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => props.step); const cssCubicBezier = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { if ( isNaN(props.cubicBezier.x1) || isNaN(props.cubicBezier.y1) || isNaN(props.cubicBezier.x1) || isNaN(props.cubicBezier.y2) ) { console.warn("The Bézier curve value must be a number"); return { x1: 0, y1: 0, x2: 1, y2: 1 }; } return props.cubicBezier; }); const cssCount = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { return props.count; }); const cssRealBoxWidth = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => realBoxWidth.value != 0 ? `${realBoxWidth.value}px` : "auto" ); const cssStartY = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { if (props.direction == "down") { return `${-realBoxHeight.value / 2}px`; } return "0"; }); const cssEndY = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { if (props.direction == "up") { return `${-realBoxHeight.value / 2}px`; } return "0"; }); const cssStartX = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { if (props.direction == "right") { return `${-realBoxWidth.value / 2}px`; } return "0"; }); const cssEndX = Object(external_commonjs_vue_commonjs2_vue_root_Vue_["computed"])(() => { if (props.direction == "left") { return `${-realBoxWidth.value / 2}px`; } return "0"; }); return { scrollRef, slotListRef, realBoxRef, scrollHtml, floatStyle, slotHtml, showHtml, enter, leave, cssStep, cssDuration, cssCount, cssCubicBezier, cssRealBoxWidth, cssStartY, cssEndY, cssStartX, cssEndX, cssPlayStatus, }; }, }); const __injectCSSVars__ = () => { Object(external_commonjs_vue_commonjs2_vue_root_Vue_["useCssVars"])(_ctx => ({ "30dfe170": (_ctx.cssRealBoxWidth), "b7b947ea": (_ctx.cssDuration), "e036a410": (_ctx.cssCount), "60e2a535": (_ctx.cssCubicBezier.x1), "60e2a554": (_ctx.cssCubicBezier.y1), "60e2a536": (_ctx.cssCubicBezier.x2), "60e2a555": (_ctx.cssCubicBezier.y2), "3dac5cfd": (_ctx.cssPlayStatus), "ef87ef26": (_ctx.cssStartX), "ef87ef24": (_ctx.cssStartY), "ac562e7a": (_ctx.cssStep), "ac631658": (_ctx.cssEndX), "ac631656": (_ctx.cssEndY) }))} const __setup__ = __default__.setup __default__.setup = __setup__ ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) } : __injectCSSVars__ /* harmony default export */ var cssSeamlessScrollvue_type_script_lang_js = (__default__); // CONCATENATED MODULE: ./package/components/cssSeamlessScroll/cssSeamlessScroll.vue?vue&type=script&lang=js // EXTERNAL MODULE: ./package/components/cssSeamlessScroll/cssSeamlessScroll.vue?vue&type=style&index=0&id=72773174&lang=css var cssSeamlessScrollvue_type_style_index_0_id_72773174_lang_css = __webpack_require__("38a8"); // CONCATENATED MODULE: ./package/components/cssSeamlessScroll/cssSeamlessScroll.vue cssSeamlessScrollvue_type_script_lang_js.render = cssSeamlessScrollvue_type_template_id_72773174_render /* harmony default export */ var cssSeamlessScroll = (cssSeamlessScrollvue_type_script_lang_js); // CONCATENATED MODULE: ./package/components/cssSeamlessScroll/index.js cssSeamlessScroll.install = (app) => { app.component(cssSeamlessScroll.name, cssSeamlessScroll) }; /* harmony default export */ var components_cssSeamlessScroll = (cssSeamlessScroll); // CONCATENATED MODULE: ./package/index.js const components = [ components_jsSeamlessScroll, components_cssSeamlessScroll ]; const install = function (app, options = {}) { components.forEach(component => { app.component(options.name || component.name, component); }); } if (typeof window !== "undefined" && window.Vue) { install(window.Vue); } /* harmony default export */ var package_0 = (install); // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js /* harmony default export */ var entry_lib = __webpack_exports__["default"] = (package_0); /***/ }) /******/ }); }); //# sourceMappingURL=vue3SeamlessScroll.umd.js.map