perf[ResizeHandler]: optimized the judgment of isMobile (#1633)

perf[ResizeHandler]: optimized the judgment of isMobile
This commit is contained in:
花裤衩 2019-02-25 17:54:10 +08:00 committed by Pan
parent 6b88c41ffc
commit c0f378e50a
1 changed files with 2 additions and 3 deletions

View File

@ -1,8 +1,7 @@
import store from '@/store' import store from '@/store'
const { body } = document const { body } = document
const WIDTH = 1024 const WIDTH = 992 // refer to Bootstrap's responsive design
const RATIO = 3
export default { export default {
watch: { watch: {
@ -25,7 +24,7 @@ export default {
methods: { methods: {
isMobile() { isMobile() {
const rect = body.getBoundingClientRect() const rect = body.getBoundingClientRect()
return rect.width - RATIO < WIDTH return rect.width - 1 < WIDTH
}, },
resizeHandler() { resizeHandler() {
if (!document.hidden) { if (!document.hidden) {