-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from frappe/develop
chore: Merge develop to main
- Loading branch information
Showing
10 changed files
with
145 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,75 @@ | ||
<template> | ||
<div ref="scrollableDiv" class="scrr" :style="`maskImage: ${maskStyle}`"> | ||
<div | ||
ref="scrollableDiv" | ||
:style="`maskImage: ${maskStyle}`" | ||
@scroll="updateMaskStyle" | ||
> | ||
<slot></slot> | ||
</div> | ||
</template> | ||
<script setup> | ||
import { ref, onMounted } from 'vue' | ||
import { ref, computed, onMounted } from 'vue' | ||
const props = defineProps({ | ||
maskHeight: { | ||
maskLength: { | ||
type: Number, | ||
default: 20, | ||
default: 30, | ||
}, | ||
orientation: { | ||
type: String, | ||
default: 'vertical', | ||
}, | ||
}) | ||
const scrollableDiv = ref(null) | ||
const maskStyle = ref('none') | ||
const side = computed(() => | ||
props.orientation == 'horizontal' ? 'right' : 'bottom' | ||
) | ||
function updateMaskStyle() { | ||
if (!scrollableDiv.value) return | ||
let scrollWidth = scrollableDiv.value.scrollWidth | ||
let clientWidth = scrollableDiv.value.clientWidth | ||
let scrollHeight = scrollableDiv.value.scrollHeight | ||
let clientHeight = scrollableDiv.value.clientHeight | ||
let scrollTop = scrollableDiv.value.scrollTop | ||
let scrollLeft = scrollableDiv.value.scrollLeft | ||
maskStyle.value = 'none' | ||
// faded on both sides | ||
if ( | ||
(side.value == 'right' && scrollWidth > clientWidth) || | ||
(side.value == 'bottom' && scrollHeight > clientHeight) | ||
) { | ||
maskStyle.value = `linear-gradient(to ${side.value}, transparent, black ${props.maskLength}px, black calc(100% - ${props.maskLength}px), transparent);` | ||
} | ||
// faded on left or top | ||
if ( | ||
(side.value == 'right' && scrollLeft - 20 > clientWidth) || | ||
(side.value == 'bottom' && scrollTop + clientHeight >= scrollHeight) | ||
) { | ||
maskStyle.value = `linear-gradient(to ${side.value}, transparent, black ${props.maskLength}px, black 100%, transparent);` | ||
} | ||
// faded on right or bottom | ||
if ( | ||
(side.value == 'right' && scrollLeft == 0) || | ||
(side.value == 'bottom' && scrollTop == 0) | ||
) { | ||
maskStyle.value = `linear-gradient(to ${side.value}, black calc(100% - ${props.maskLength}px), transparent 100%);` | ||
} | ||
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 { | ||
if ( | ||
(side.value == 'right' && clientWidth == scrollWidth) || | ||
(side.value == 'bottom' && clientHeight == scrollHeight) | ||
) { | ||
maskStyle.value = 'none' | ||
} | ||
} | ||
onMounted(() => setMaskStyle()) | ||
onMounted(() => setTimeout(() => updateMaskStyle(), 300)) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.