fix: added fadedScrollableDiv component

This commit is contained in:
Shariq Ansari 2024-05-13 21:15:32 +05:30
parent 7ddb782165
commit bc8ba484c3

View File

@ -0,0 +1,29 @@
<template>
<div ref="scrollableDiv" class="scrr" :style="`maskImage: ${maskStyle}`">
<slot></slot>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue'
const props = defineProps({
maskHeight: {
type: Number,
default: 20,
},
})
const scrollableDiv = ref(null)
const maskStyle = ref('none')
function setMaskStyle() {
// show mask only if div is scrollable
if (scrollableDiv.value.scrollHeight > scrollableDiv.value.clientHeight) {
maskStyle.value = `linear-gradient(to bottom, black calc(100% - ${props.maskHeight}px), transparent 100%);`
} else {
maskStyle.value = 'none'
}
}
onMounted(() => setMaskStyle())
</script>