11<template >
2- <div id =" header" >
2+ <div id =" header" :style = " headerStyle " >
33 <Menu
44 ref="menuRef"
55 class="header-menu"
111111 :width =" 400 "
112112 :styles =" { top: modalStatus .mode === ' login' ? ' 10%' : ' 2%' } "
113113 >
114- <div slot =" header" class =" modal-title" style =" text-align : center " >
115- {{
116- modalStatus.mode === "login"
117- ? $t("m.LoginModalHeader")
118- : $t("m.RegisterModalHeader")
119- }}
114+ <div slot =" header" class =" modal-title" >
115+ <div class =" modal-heading" >
116+ {{
117+ modalStatus.mode === "login"
118+ ? $t("m.LoginModalHeader")
119+ : $t("m.RegisterModalHeader")
120+ }}
121+ </div >
120122 </div >
121123 <component :is =" modalStatus.mode" v-if =" modalVisible" ></component >
122124 <div slot =" footer" style =" display : none " ></div >
@@ -139,12 +141,18 @@ export default {
139141 mounted () {
140142 this .getProfile ()
141143 this .$nextTick (this .initIndicator )
144+ this .syncHeaderScroll ()
145+ window .addEventListener (" scroll" , this .handleWindowScroll , { passive: true })
142146 },
143147 beforeDestroy () {
144148 if (this .communityDropdownTimer ) {
145149 clearTimeout (this .communityDropdownTimer )
146150 this .communityDropdownTimer = null
147151 }
152+ window .removeEventListener (" scroll" , this .handleWindowScroll )
153+ if (this ._headerScrollFrame ) {
154+ cancelAnimationFrame (this ._headerScrollFrame )
155+ }
148156 this .teardownIndicator ()
149157 },
150158 data () {
@@ -157,6 +165,7 @@ export default {
157165 visible: false ,
158166 },
159167 indicatorReady: false ,
168+ headerOffsetX: 0 ,
160169 }
161170 },
162171 methods: {
@@ -192,6 +201,17 @@ export default {
192201 mode: mode,
193202 })
194203 },
204+ handleWindowScroll () {
205+ if (this ._headerScrollFrame ) return
206+ this ._headerScrollFrame = requestAnimationFrame (() => {
207+ this ._headerScrollFrame = null
208+ this .syncHeaderScroll ()
209+ })
210+ },
211+ syncHeaderScroll () {
212+ this .headerOffsetX = window .pageXOffset || window .scrollX || 0
213+ this .scheduleIndicatorUpdate ()
214+ },
195215 initIndicator () {
196216 const menuEl = this .$refs .menuRef && this .$refs .menuRef .$el
197217 if (! menuEl) return
@@ -335,6 +355,11 @@ export default {
335355 width: this .indicator .width + " px" ,
336356 }
337357 },
358+ headerStyle () {
359+ return {
360+ transform: ` translateX(${ - this .headerOffsetX } px)` ,
361+ }
362+ },
338363 modalVisible: {
339364 get () {
340365 return this .modalStatus .visible
@@ -618,6 +643,22 @@ export default {
618643 &-title {
619644 font-size : 18px ;
620645 font-weight : 1000 ;
646+ text-align : center ;
647+ }
648+
649+ &-heading {
650+ color : #17193d ;
651+ font-size : inherit ;
652+ font-weight : inherit ;
653+ line-height : inherit ;
654+ }
655+
656+ &-subtitle {
657+ margin-top : 6px ;
658+ color : #7b8191 ;
659+ font-size : 12px ;
660+ font-weight : 500 ;
661+ line-height : 1.4 ;
621662 }
622663}
623664
0 commit comments