Browse Source

perf[ResizeHandler]: optimized the judgment of isMobile

Pan 6 years ago
parent
commit
7725f72beb
1 changed files with 2 additions and 3 deletions
  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) {