File tree 3 files changed +33
-6
lines changed
3 files changed +33
-6
lines changed Original file line number Diff line number Diff line change 88
88
.md-app-toolbar {
89
89
position : fixed ;
90
90
top : 0 ;
91
+ transition : none ;
91
92
}
92
93
}
93
94
}
Original file line number Diff line number Diff line change @@ -37,7 +37,8 @@ export default {
37
37
toolbar : {
38
38
element : null ,
39
39
transformY : 0 ,
40
- hasElevation : true
40
+ hasElevation : true ,
41
+ revealActive : false
41
42
} ,
42
43
drawer : {
43
44
active : false ,
@@ -95,11 +96,26 @@ export default {
95
96
this . MdApp . toolbar . hasElevation = $event . target . scrollTop >= threshold
96
97
} ,
97
98
handleRevealMode ( $event ) {
98
- /* const height = this.MdApp.toolbar.element.offsetHeight
99
- const threshold = height + 10 */
99
+ const toolbarHeight = this . MdApp . toolbar . element . offsetHeight
100
+ const safeAmount = 10
101
+ const threshold = toolbarHeight + safeAmount
100
102
const scrollTop = $event . target . scrollTop
101
103
102
- this . MdApp . toolbar . transformY = scrollTop
104
+ window . clearTimeout ( this . revealTimer )
105
+
106
+ this . revealTimer = window . setTimeout ( ( ) => {
107
+ this . revealLastPos = scrollTop
108
+ } , 100 )
109
+
110
+ if ( this . revealLastPos > scrollTop + safeAmount ) {
111
+ this . MdApp . toolbar . revealActive = true
112
+ this . MdApp . toolbar . transformY = scrollTop - threshold
113
+ } else if ( scrollTop < threshold ) {
114
+ this . MdApp . toolbar . revealActive = false
115
+ this . MdApp . toolbar . transformY = 0
116
+ } else {
117
+ this . MdApp . toolbar . transformY = scrollTop - threshold
118
+ }
103
119
} ,
104
120
handleModeScroll ( $event ) {
105
121
if ( this . mdMode === 'reveal' ) {
Original file line number Diff line number Diff line change 11
11
computed: {
12
12
toolbarClasses () {
13
13
return {
14
- ' md-no-elevation' : ! this .MdApp .toolbar .hasElevation
14
+ ' md-no-elevation' : ! this .MdApp .toolbar .hasElevation ,
15
+ ' md-reveal-active' : this .MdApp .toolbar .revealActive
15
16
}
16
17
},
17
18
toolbarStyles () {
18
19
return {
19
- transform : ` translate3D(0, ${ this .MdApp .toolbar .transformY } px, 0) `
20
+ ' margin-top ' : ` ${ this .MdApp .toolbar .transformY } px`
20
21
}
21
22
}
22
23
},
27
28
</script >
28
29
29
30
<style lang="scss" scoped>
31
+ @import " ~components/MdAnimation/variables" ;
32
+
30
33
.md-no-elevation {
31
34
box-shadow : none !important ;
32
35
}
36
+
37
+ .md-reveal .md-reveal-active {
38
+ transform : translate3d (0 , calc (100% + 10px ), 0 );
39
+ transition : .3s $md-transition-stand-timing ;
40
+ transition-property : box-shadow , transform ;
41
+ will-change : box-shadow , transform ;
42
+ }
33
43
</style >
You can’t perform that action at this time.
0 commit comments