浏览代码

perf[ResizeHandler]: optimized the judgment of isMobile

Pan 6 年之前
父节点
当前提交
7725f72beb
共有 1 个文件被更改,包括 2 次插入3 次删除
  1. 2 3
      src/views/layout/mixin/ResizeHandler.js

+ 2 - 3
src/views/layout/mixin/ResizeHandler.js

@@ -1,8 +1,7 @@
 import store from '@/store'
 import store from '@/store'
 
 
 const { body } = document
 const { body } = document
-const WIDTH = 1024
-const RATIO = 3
+const WIDTH = 992 // refer to Bootstrap's responsive design
 
 
 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) {