remove window width copypasta
This commit is contained in:
parent
c06bcf3303
commit
2879495b8a
3 changed files with 11 additions and 5 deletions
|
@ -10,6 +10,7 @@ import MediaModal from './components/media_modal/media_modal.vue'
|
||||||
import SideDrawer from './components/side_drawer/side_drawer.vue'
|
import SideDrawer from './components/side_drawer/side_drawer.vue'
|
||||||
import MobilePostStatusModal from './components/mobile_post_status_modal/mobile_post_status_modal.vue'
|
import MobilePostStatusModal from './components/mobile_post_status_modal/mobile_post_status_modal.vue'
|
||||||
import MobileNav from './components/mobile_nav/mobile_nav.vue'
|
import MobileNav from './components/mobile_nav/mobile_nav.vue'
|
||||||
|
import { windowWidth } from './services/window_utils/window_utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'app',
|
name: 'app',
|
||||||
|
@ -102,10 +103,10 @@ export default {
|
||||||
this.finderHidden = hidden
|
this.finderHidden = hidden
|
||||||
},
|
},
|
||||||
updateMobileState () {
|
updateMobileState () {
|
||||||
const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
|
const mobileLayout = windowWidth() <= 800
|
||||||
const changed = width <= 800 !== this.isMobileLayout
|
const changed = mobileLayout !== this.isMobileLayout
|
||||||
if (changed) {
|
if (changed) {
|
||||||
this.$store.dispatch('setMobileLayout', width <= 800)
|
this.$store.dispatch('setMobileLayout', mobileLayout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import VueRouter from 'vue-router'
|
import VueRouter from 'vue-router'
|
||||||
import routes from './routes'
|
import routes from './routes'
|
||||||
|
|
||||||
import App from '../App.vue'
|
import App from '../App.vue'
|
||||||
|
import { windowWidth } from '../services/window_utils/window_utils'
|
||||||
|
|
||||||
const getStatusnetConfig = async ({ store }) => {
|
const getStatusnetConfig = async ({ store }) => {
|
||||||
try {
|
try {
|
||||||
|
@ -230,7 +230,7 @@ const afterStoreSetup = async ({ store, i18n }) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
|
const width = windowWidth()
|
||||||
store.dispatch('setMobileLayout', width <= 800)
|
store.dispatch('setMobileLayout', width <= 800)
|
||||||
|
|
||||||
const apiConfig = await getStatusnetConfig({ store })
|
const apiConfig = await getStatusnetConfig({ store })
|
||||||
|
|
5
src/services/window_utils/window_utils.js
Normal file
5
src/services/window_utils/window_utils.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
export const windowWidth = () =>
|
||||||
|
window.innerWidth ||
|
||||||
|
document.documentElement.clientWidth ||
|
||||||
|
document.body.clientWidth
|
Loading…
Reference in a new issue