LoongPanel-Asp/web/components/XScroll.vue

51 lines
1013 B
Vue
Raw Normal View History

2024-06-22 10:54:02 +08:00
<script lang="ts" setup>
const el = ref(null)
const boxEl = ref(null)
const {width, height} = useElementSize(el)
const {width: boxWidth, height: boxHeight} = useElementSize(boxEl)
</script>
<template>
<div ref="boxEl" class="scroll-container">
<div class="v-scroll">
<div ref="el" class="content">
<slot></slot>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
2024-06-29 18:16:29 +08:00
@import "base";
2024-06-22 10:54:02 +08:00
.scroll-container {
--w: calc(v-bind('width') * 1px);
--h: calc(v-bind('height') * 1px);
--bw: calc(v-bind('boxWidth') * 1px);
--bh: calc(v-bind('boxHeight') * 1px);
width: 100%;
height: var(--h);
}
.v-scroll {
height: var(--bw);
width: var(--bh);
position: relative;
transform-origin: left top;
overflow: auto;
&::-webkit-scrollbar {
display: none;
}
transform: rotate(-90deg) translateX(calc(var(--bh) * -1));
}
.content {
position: absolute;
left: var(--h);
2024-06-29 18:16:29 +08:00
width: var(--bw);
2024-06-22 10:54:02 +08:00
transform-origin: left top;
transform: rotate(90deg);
}
</style>