You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
6.4 KiB
1 line
6.4 KiB
{"ast":null,"code":"import { defineComponent, inject, ref, openBlock, createElementBlock, Fragment, createVNode } from 'vue';\nimport { GAP } from './util.mjs';\nimport Thumb from './thumb2.mjs';\nimport { barProps } from './bar.mjs';\nimport { scrollbarContextKey } from './constants.mjs';\nimport _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';\nconst _sfc_main = /* @__PURE__ */defineComponent({\n __name: \"bar\",\n props: barProps,\n setup(__props, {\n expose\n }) {\n const props = __props;\n const scrollbar = inject(scrollbarContextKey);\n const moveX = ref(0);\n const moveY = ref(0);\n const sizeWidth = ref(\"\");\n const sizeHeight = ref(\"\");\n const ratioY = ref(1);\n const ratioX = ref(1);\n const handleScroll = wrap => {\n if (wrap) {\n const offsetHeight = wrap.offsetHeight - GAP;\n const offsetWidth = wrap.offsetWidth - GAP;\n moveY.value = wrap.scrollTop * 100 / offsetHeight * ratioY.value;\n moveX.value = wrap.scrollLeft * 100 / offsetWidth * ratioX.value;\n }\n };\n const update = () => {\n const wrap = scrollbar == null ? void 0 : scrollbar.wrapElement;\n if (!wrap) return;\n const offsetHeight = wrap.offsetHeight - GAP;\n const offsetWidth = wrap.offsetWidth - GAP;\n const originalHeight = offsetHeight ** 2 / wrap.scrollHeight;\n const originalWidth = offsetWidth ** 2 / wrap.scrollWidth;\n const height = Math.max(originalHeight, props.minSize);\n const width = Math.max(originalWidth, props.minSize);\n ratioY.value = originalHeight / (offsetHeight - originalHeight) / (height / (offsetHeight - height));\n ratioX.value = originalWidth / (offsetWidth - originalWidth) / (width / (offsetWidth - width));\n sizeHeight.value = height + GAP < offsetHeight ? `${height}px` : \"\";\n sizeWidth.value = width + GAP < offsetWidth ? `${width}px` : \"\";\n };\n expose({\n handleScroll,\n update\n });\n return (_ctx, _cache) => {\n return openBlock(), createElementBlock(Fragment, null, [createVNode(Thumb, {\n move: moveX.value,\n ratio: ratioX.value,\n size: sizeWidth.value,\n always: _ctx.always\n }, null, 8, [\"move\", \"ratio\", \"size\", \"always\"]), createVNode(Thumb, {\n move: moveY.value,\n ratio: ratioY.value,\n size: sizeHeight.value,\n vertical: \"\",\n always: _ctx.always\n }, null, 8, [\"move\", \"ratio\", \"size\", \"always\"])], 64);\n };\n }\n});\nvar Bar = /* @__PURE__ */_export_sfc(_sfc_main, [[\"__file\", \"bar.vue\"]]);\nexport { Bar as default };","map":{"version":3,"names":["scrollbar","inject","scrollbarContextKey","moveX","ref","moveY","sizeWidth","sizeHeight","ratioY","ratioX","handleScroll","wrap","offsetHeight","GAP","offsetWidth","value","scrollTop","scrollLeft","update","wrapElement","originalHeight","scrollHeight","originalWidth","scrollWidth","height","Math","max","props","minSize","width","expose"],"sources":["../../../../../../packages/components/scrollbar/src/bar.vue"],"sourcesContent":["<template>\n <thumb :move=\"moveX\" :ratio=\"ratioX\" :size=\"sizeWidth\" :always=\"always\" />\n <thumb\n :move=\"moveY\"\n :ratio=\"ratioY\"\n :size=\"sizeHeight\"\n vertical\n :always=\"always\"\n />\n</template>\n<script lang=\"ts\" setup>\nimport { inject, ref } from 'vue'\nimport { GAP } from './util'\nimport Thumb from './thumb.vue'\nimport { barProps } from './bar'\nimport { scrollbarContextKey } from './constants'\n\nconst props = defineProps(barProps)\n\nconst scrollbar = inject(scrollbarContextKey)\n\nconst moveX = ref(0)\nconst moveY = ref(0)\nconst sizeWidth = ref('')\nconst sizeHeight = ref('')\nconst ratioY = ref(1)\nconst ratioX = ref(1)\n\nconst handleScroll = (wrap: HTMLDivElement) => {\n if (wrap) {\n const offsetHeight = wrap.offsetHeight - GAP\n const offsetWidth = wrap.offsetWidth - GAP\n\n moveY.value = ((wrap.scrollTop * 100) / offsetHeight) * ratioY.value\n moveX.value = ((wrap.scrollLeft * 100) / offsetWidth) * ratioX.value\n }\n}\n\nconst update = () => {\n const wrap = scrollbar?.wrapElement\n if (!wrap) return\n const offsetHeight = wrap.offsetHeight - GAP\n const offsetWidth = wrap.offsetWidth - GAP\n\n const originalHeight = offsetHeight ** 2 / wrap.scrollHeight\n const originalWidth = offsetWidth ** 2 / wrap.scrollWidth\n const height = Math.max(originalHeight, props.minSize)\n const width = Math.max(originalWidth, props.minSize)\n\n ratioY.value =\n originalHeight /\n (offsetHeight - originalHeight) /\n (height / (offsetHeight - height))\n ratioX.value =\n originalWidth /\n (offsetWidth - originalWidth) /\n (width / (offsetWidth - width))\n\n sizeHeight.value = height + GAP < offsetHeight ? `${height}px` : ''\n sizeWidth.value = width + GAP < offsetWidth ? `${width}px` : ''\n}\n\ndefineExpose({\n handleScroll,\n update,\n})\n</script>\n"],"mappings":";;;;;;;;;;;;;IAmBM,MAAAA,SAAA,GAAYC,MAAA,CAAOC,mBAAmB;IAEtC,MAAAC,KAAA,GAAQC,GAAA,CAAI,CAAC;IACb,MAAAC,KAAA,GAAQD,GAAA,CAAI,CAAC;IACb,MAAAE,SAAA,GAAYF,GAAA,CAAI,EAAE;IAClB,MAAAG,UAAA,GAAaH,GAAA,CAAI,EAAE;IACnB,MAAAI,MAAA,GAASJ,GAAA,CAAI,CAAC;IACd,MAAAK,MAAA,GAASL,GAAA,CAAI,CAAC;IAEd,MAAAM,YAAA,GAAgBC,IAAyB;MAC7C,IAAIA,IAAM;QACF,MAAAC,YAAA,GAAeD,IAAA,CAAKC,YAAe,GAAAC,GAAA;QACnC,MAAAC,WAAA,GAAcH,IAAA,CAAKG,WAAc,GAAAD,GAAA;QAEvCR,KAAA,CAAMU,KAAU,GAAAJ,IAAA,CAAKK,SAAY,SAAOJ,YAAA,GAAgBJ,MAAO,CAAAO,KAAA;QAC/DZ,KAAA,CAAMY,KAAU,GAAAJ,IAAA,CAAKM,UAAa,SAAOH,WAAA,GAAeL,MAAO,CAAAM,KAAA;MAAA;IACjE,CACF;IAEA,MAAMG,MAAA,GAASA,CAAA,KAAM;MACnB,MAAMP,IAAA,GAAOX,SAAW,oBAAAA,SAAA,CAAAmB,WAAA;MACx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