Skip to content
Snippets Groups Projects
Commit e697d7ea authored by Angelina Filippova's avatar Angelina Filippova
Browse files

Add support of tablet device in ResizeHandler

parent 43693410
No related branches found
No related tags found
1 merge request!93Add styles for tablets
import store from '@/store'
const { body } = document
const WIDTH = 1024
const RATIO = 3
const mobileWidth = 480
const tabletWidth = 801
const ratio = 3
export default {
watch: {
......@@ -17,23 +18,31 @@ export default {
},
mounted() {
const isMobile = this.isMobile()
if (isMobile) {
store.dispatch('toggleDevice', 'mobile')
const isTablet = this.isTablet()
if (isMobile || isTablet) {
store.dispatch('toggleDevice', isMobile ? 'mobile' : 'tablet')
store.dispatch('closeSideBar', { withoutAnimation: true })
}
},
methods: {
isMobile() {
const rect = body.getBoundingClientRect()
return rect.width - RATIO < WIDTH
return rect.width - ratio < mobileWidth
},
isTablet() {
const rect = body.getBoundingClientRect()
return rect.width - ratio < tabletWidth && rect.width - ratio > mobileWidth
},
resizeHandler() {
if (!document.hidden) {
const isMobile = this.isMobile()
store.dispatch('toggleDevice', isMobile ? 'mobile' : 'desktop')
const isTablet = this.isTablet()
if (isMobile) {
if (isMobile || isTablet) {
store.dispatch('toggleDevice', isMobile ? 'mobile' : 'tablet')
store.dispatch('closeSideBar', { withoutAnimation: true })
} else {
store.dispatch('toggleDevice', 'desktop')
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment