File tree 2 files changed +29
-0
lines changed
components/VAppBar/__tests__
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,28 @@ describe('VAppBar', () => {
84
84
. get ( '.v-app-bar' ) . should ( 'not.be.visible' )
85
85
} )
86
86
87
+ it ( 'should hide correctly when scroll to the bottom' , ( ) => {
88
+ cy . mount ( ( { scrollBehavior } : any ) => (
89
+ < VLayout >
90
+ < VAppBar scrollBehavior = { scrollBehavior } />
91
+
92
+ < VMain style = "min-height: 300px" >
93
+ {
94
+ Array . from ( { length : 7 } , ( ) => (
95
+ < div class = "pa-16 ma-2 w-50 bg-green text-center" >
96
+ box
97
+ </ div >
98
+ ) )
99
+ }
100
+ </ VMain >
101
+ </ VLayout >
102
+ ) )
103
+ . setProps ( { scrollBehavior : 'hide' } )
104
+ . get ( '.v-app-bar' ) . should ( 'be.visible' )
105
+ . window ( ) . scrollTo ( 'bottom' )
106
+ . get ( '.v-app-bar' ) . should ( 'not.be.visible' )
107
+ } )
108
+
87
109
it ( 'collapses' , ( ) => {
88
110
cy . mount ( ( { scrollBehavior } : any ) => (
89
111
< VLayout >
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ export function useScroll (
44
44
) {
45
45
const { canScroll } = args
46
46
let previousScroll = 0
47
+ let previousScrollHeight = 0
47
48
const target = ref < Element | Window | null > ( null )
48
49
const currentScroll = shallowRef ( 0 )
49
50
const savedScroll = shallowRef ( 0 )
@@ -71,6 +72,12 @@ export function useScroll (
71
72
previousScroll = currentScroll . value
72
73
currentScroll . value = ( 'window' in targetEl ) ? targetEl . pageYOffset : targetEl . scrollTop
73
74
75
+ const currentScrollHeight = targetEl instanceof Window ? document . documentElement . scrollHeight : targetEl . scrollHeight
76
+ if ( previousScrollHeight !== currentScrollHeight ) {
77
+ previousScrollHeight = currentScrollHeight
78
+ return
79
+ }
80
+
74
81
isScrollingUp . value = currentScroll . value < previousScroll
75
82
currentThreshold . value = Math . abs ( currentScroll . value - scrollThreshold . value )
76
83
}
You can’t perform that action at this time.
0 commit comments