瀏覽代碼

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 @@
1
 import store from '@/store'
1
 import store from '@/store'
2
 
2
 
3
 const { body } = document
3
 const { body } = document
4
-const WIDTH = 1024
5
-const RATIO = 3
4
+const WIDTH = 992 // refer to Bootstrap's responsive design
6
 
5
 
7
 export default {
6
 export default {
8
   watch: {
7
   watch: {
@@ -25,7 +24,7 @@ export default {
25
   methods: {
24
   methods: {
26
     isMobile() {
25
     isMobile() {
27
       const rect = body.getBoundingClientRect()
26
       const rect = body.getBoundingClientRect()
28
-      return rect.width - RATIO < WIDTH
27
+      return rect.width - 1 < WIDTH
29
     },
28
     },
30
     resizeHandler() {
29
     resizeHandler() {
31
       if (!document.hidden) {
30
       if (!document.hidden) {