55 @touchstart =" onTouchStart"
66 @touchend =" onTouchEnd"
77 >
8- <VueMasteryBanner
9- v-if =" isBannerOpen"
10- @close-banner =" closeBanner"
11- ref =" vueMasteryBanner"
12- />
138 <Navbar v-if =" shouldShowNavbar" @toggle-sidebar =" toggleSidebar" />
149
1510 <div class =" sidebar-mask" @click =" toggleSidebar(false)" />
@@ -53,7 +48,6 @@ import Home from '@theme/components/Home.vue'
5348import Navbar from ' @theme/components/Navbar.vue'
5449import Page from ' @theme/components/Page.vue'
5550import Sidebar from ' @theme/components/Sidebar.vue'
56- import VueMasteryBanner from ' @theme/components/sponsors/VueMasteryBanner.vue'
5751import BuySellAds from ' @theme/components/BuySellAds.vue'
5852import CarbonAds from ' @theme/components/CarbonAds.vue'
5953import { resolveSidebarItems } from ' ../util'
@@ -66,18 +60,13 @@ export default {
6660 Page,
6761 Sidebar,
6862 Navbar,
69- VueMasteryBanner,
7063 BuySellAds,
7164 CarbonAds
7265 },
7366
7467 data () {
7568 return {
76- isSidebarOpen: false ,
77- isBannerOpen: true ,
78- isMenuFixed: false ,
79- nameStorage: ' vuemastery-black-firday-2020-banner' ,
80- menuPosition: 0
69+ isSidebarOpen: false
8170 }
8271 },
8372
@@ -121,9 +110,7 @@ export default {
121110 {
122111 ' no-navbar' : ! this .shouldShowNavbar ,
123112 ' sidebar-open' : this .isSidebarOpen ,
124- ' no-sidebar' : ! this .shouldShowSidebar ,
125- ' vuemastery-menu-fixed' : this .isMenuFixed ,
126- ' vuemastery-promo' : this .isBannerOpen
113+ ' no-sidebar' : ! this .shouldShowSidebar
127114 },
128115 userPageClass
129116 ]
@@ -138,13 +125,6 @@ export default {
138125 this .$router .afterEach (() => {
139126 this .isSidebarOpen = false
140127 })
141-
142- // Load component according to user preferences
143- if (! localStorage .getItem (this .nameStorage )) {
144- this .initBanner ()
145- } else {
146- this .isBannerOpen = false
147- }
148128 },
149129
150130 methods: {
@@ -171,54 +151,6 @@ export default {
171151 this .toggleSidebar (false )
172152 }
173153 }
174- },
175-
176- // Vue Mastery Banner
177- initBanner () {
178- // Add event listeners
179- this .toggleBannerEvents (true )
180- // Add class to the body to push fixed elements
181- this .isBannerOpen = true
182- // Get the menu position
183- this .getMenuPosition ()
184- // Check current page offset position
185- this .isMenuFixed = this .isUnderBanner ()
186- },
187-
188- closeBanner (e ) {
189- // Remove events
190- this .toggleBannerEvents (false )
191- // Hide the banner
192- this .isBannerOpen = false
193- // Save action in the local storage
194- localStorage .setItem (this .nameStorage , true )
195- },
196-
197- getMenuPosition () {
198- this .menuPosition = this .$refs .vueMasteryBanner .$el .clientHeight
199- },
200-
201- isUnderBanner () {
202- return window .pageYOffset > this .menuPosition
203- },
204-
205- fixMenuAfterBanner () {
206- if (this .isUnderBanner ()) {
207- if (! this .isMenuFixed ) {
208- // The menu will be fixed
209- this .isMenuFixed = true
210- }
211- } else if (this .isMenuFixed ) {
212- // The menu stay under the banner
213- this .isMenuFixed = false
214- }
215- },
216-
217- toggleBannerEvents (on ) {
218- // Add or remove event listerners attached to the DOM
219- let method = on ? ' addEventListener' : ' removeEventListener'
220- window [method](' resize' , this .getMenuPosition )
221- window [method](' scroll' , this .fixMenuAfterBanner )
222154 }
223155 }
224156}
0 commit comments