UNPKG

@opensig/opendesign

Version:

37 lines (36 loc) 1.18 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const vue = require("vue"); const is = require("../../_utils/is.js"); const useLifecycle = (props, initData, resetSize) => { const slider = vue.ref(); vue.onMounted(async () => { if (props.range) { if (is.isArray(props.modelValue)) { initData.firstBtnVal = Math.max(props.min, props.modelValue[0]); initData.secondBtnVal = Math.min(props.max, props.modelValue[1]); } else { initData.firstBtnVal = props.min; initData.secondBtnVal = props.max; } initData.oldValue = [initData.firstBtnVal, initData.secondBtnVal]; } else { if (!is.isNumber(props.modelValue)) { initData.firstBtnVal = props.min; } else { initData.firstBtnVal = Math.min(props.max, Math.max(props.min, props.modelValue)); } initData.oldValue = initData.firstBtnVal; } window.addEventListener("resize", resetSize); await vue.nextTick(); resetSize(); }); vue.onUnmounted(() => { window.removeEventListener("resize", resetSize); }); return { slider }; }; exports.useLifecycle = useLifecycle;