Skip to content

Commit

Permalink
chore: 滚动条始终显示
Browse files Browse the repository at this point in the history
  • Loading branch information
StreakingMan committed Jan 27, 2024
1 parent e12d26a commit dc8ffc9
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/components/core/Sketch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,12 @@ const wrapperRef = ref<HTMLDivElement | null>(null);
const grabbing = ref(false);
const scrolling = ref(false);
const setUnScrollingDebounce = useDebounceFn(() => {
scrolling.value = false;
}, 300);
// 优化Mac触控板滚动(屏蔽默认行为,重新赋值两个轴的偏移量)
const handleSketchWheel = (e: WheelEvent) => {
if (!wrapperRef.value || e.ctrlKey) return;
e.preventDefault();
wrapperRef.value.scrollLeft += e.deltaX;
wrapperRef.value.scrollTop += e.deltaY;
scrolling.value = true;
setTimeout(() => {
setUnScrollingDebounce();
}, 300);
};
onMounted(() => {
Expand Down Expand Up @@ -166,14 +158,7 @@ const gapY = computed(() => {
</script>

<template>
<div
ref="wrapperRef"
class="sketch__wrapper"
:style="[
`--scroll-thumb-color: ${scrolling ? 'rgba(255,255,255,0.3)' : 'transparent'}`,
{ cursor },
]"
>
<div ref="wrapperRef" class="sketch__wrapper" :style="{ cursor }">
<div
class="sketch__inner"
:style="{
Expand Down Expand Up @@ -212,7 +197,7 @@ const gapY = computed(() => {
&::-webkit-scrollbar-thumb {
transition: background-color 0.3s;
border-radius: 6px;
background-color: var(--scroll-thumb-color);
background-color: #2a2a2a;
}
}
Expand Down

1 comment on commit dc8ffc9

@vercel
Copy link

@vercel vercel bot commented on dc8ffc9 Jan 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.