UNPKG

wetrade-design

Version:

一款多语言支持Vue3的UI框架

61 lines 1.58 kB
import { createVNode as _createVNode, Fragment as _Fragment } from "vue"; import { ref, defineComponent } from 'vue'; import { GAP } from './utils'; import Thumb from './thumb'; export var barProps = function barProps() { return { always: { type: Boolean, default: true }, width: String, height: String, ratioX: { type: Number, default: 1 }, ratioY: { type: Number, default: 1 } }; }; var Bar = defineComponent({ props: barProps(), setup: function setup(props, _ref) { var expose = _ref.expose; var moveX = ref(0); var moveY = ref(0); var handleScroll = function handleScroll(wrap) { if (wrap) { var offsetHeight = wrap.offsetHeight - GAP; var offsetWidth = wrap.offsetWidth - GAP; moveY.value = wrap.scrollTop * 100 / offsetHeight * props.ratioY; moveX.value = wrap.scrollLeft * 100 / offsetWidth * props.ratioX; } }; expose({ handleScroll: handleScroll }); return function () { var ratioX = props.ratioX, ratioY = props.ratioY, width = props.width, height = props.height, always = props.always; return _createVNode(_Fragment, null, [_createVNode(Thumb, { "move": moveX.value, "ratio": ratioX, "size": width, "always": always }, null), _createVNode(Thumb, { "move": moveY.value, "ratio": ratioY, "size": height, "vertical": true, "always": always }, null)]); }; } }); export default Bar;