@@ -8,12 +8,12 @@ SPDX-License-Identifier: Apache-2.0
88 <div
99 class =" scroll-wrapper"
1010 :class =" wrapperClasses"
11- :style =" cssVars"
1211 >
1312 <div
1413 ref =" scrollRef"
1514 class =" scrollable-container"
1615 :class =" containerClasses"
16+ :style =" maskStyle"
1717 >
1818 <div
1919 ref =" contentRef"
@@ -86,6 +86,28 @@ const fadeOpacity = computed(() => {
8686 return remainingY / fadeSize .value
8787})
8888
89+ const maskStyle = computed (() => {
90+ if (fadeOpacity .value <= 0 ) {
91+ return {}
92+ }
93+
94+ const effectiveFadeSize = Math .round (fadeSize .value * fadeOpacity .value )
95+
96+ if (direction .value === ' horizontal' ) {
97+ const gradient = ` linear-gradient(to right, black 0, black calc(100% - ${ effectiveFadeSize} px), transparent 100%)`
98+ return {
99+ maskImage: gradient,
100+ WebkitMaskImage: gradient,
101+ }
102+ }
103+
104+ const gradient = ` linear-gradient(to bottom, black 0, black calc(100% - ${ effectiveFadeSize} px), transparent 100%)`
105+ return {
106+ maskImage: gradient,
107+ WebkitMaskImage: gradient,
108+ }
109+ })
110+
89111const wrapperClasses = computed (() => ({
90112 ' scroll-wrapper--vertical' : direction .value === ' vertical' ,
91113 ' scroll-wrapper--horizontal' : direction .value === ' horizontal' ,
@@ -95,20 +117,17 @@ const containerClasses = computed(() => ({
95117 ' scrollable-container--vertical' : direction .value === ' vertical' ,
96118 ' scrollable-container--horizontal' : direction .value === ' horizontal' ,
97119}))
98-
99- const cssVars = computed (() => ({
100- ' --fadeOpacity' : fadeOpacity .value ,
101- ' --fadeSize' : ` ${ fadeSize .value } px` ,
102- }))
103120 </script >
104121
105122<style scoped>
106123.scroll-wrapper {
107124 position : relative ;
125+ overflow : hidden ;
108126}
109127
110128.scrollable-container--vertical {
111129 overflow-y : auto ;
130+ max-height : inherit ;
112131}
113132
114133.scrollable-container--horizontal {
@@ -125,32 +144,4 @@ const cssVars = computed(() => ({
125144 display : inline-flex ;
126145 white-space : nowrap ;
127146}
128-
129- /* Vertical: bottom fade - on the non-scrolling wrapper */
130- .scroll-wrapper--vertical ::after {
131- content : " " ;
132- position : absolute ;
133- left : 0 ;
134- bottom : 0 ;
135- width : 100% ;
136- height : var (--fadeSize );
137- background : linear-gradient (to bottom , rgba (255 , 255 , 255 , 0 ), rgba (var (--v-theme-surface )));
138- pointer-events : none ;
139- opacity : var (--fadeOpacity );
140- z-index : 1 ;
141- }
142-
143- /* Horizontal: right fade - on the non-scrolling wrapper */
144- .scroll-wrapper--horizontal ::after {
145- content : " " ;
146- position : absolute ;
147- right : 0 ;
148- top : 0 ;
149- height : 100% ;
150- width : var (--fadeSize );
151- background : linear-gradient (to right , rgba (255 , 255 , 255 , 0 ), rgba (var (--v-theme-surface )));
152- pointer-events : none ;
153- opacity : var (--fadeOpacity );
154- z-index : 1 ;
155- }
156147 </style >
0 commit comments