Переглянути джерело

simplify back and just use css class

Artur Paikin 7 роки тому
батько
коміт
daeea9d7fa
3 змінених файлів з 10 додано та 26 видалено
  1. 7 22
      src/plugins/Dashboard/index.js
  2. 1 2
      src/scss/_dashboard.scss
  3. 2 2
      website/package.json

+ 7 - 22
src/plugins/Dashboard/index.js

@@ -201,20 +201,6 @@ module.exports = class Dashboard extends Plugin {
     }
     }
   }
   }
 
 
-  scrollBehaviour (toggle) {
-    if (!this.opts.disablePageScrollWhenModalOpen) return
-    const body = document.querySelector('body')
-    switch (toggle) {
-      case 'enable':
-        Object.assign(body.style, { overflow: 'initial', height: 'initial' })
-        break
-      case 'disable':
-        Object.assign(body.style, { overflow: 'hidden', height: '100vh' })
-        break
-      default:
-    }
-  }
-
   openModal () {
   openModal () {
     this.setPluginState({
     this.setPluginState({
       isHidden: false
       isHidden: false
@@ -225,12 +211,10 @@ module.exports = class Dashboard extends Plugin {
     // save active element, so we can restore focus when modal is closed
     // save active element, so we can restore focus when modal is closed
     this.savedActiveElement = document.activeElement
     this.savedActiveElement = document.activeElement
 
 
-    // add class to body that sets position fixed, move everything back
-    // to scroll position
-    // document.body.classList.add('uppy-Dashboard-isOpen')
-    // document.body.style.top = `-${this.savedScrollPosition}px`
+    if (!this.opts.disablePageScrollWhenModalOpen) {
+      document.body.classList.remove('uppy-Dashboard-isOpen')
+    }
 
 
-    this.scrollBehaviour('disable')
     this.updateDashboardElWidth()
     this.updateDashboardElWidth()
     this.setFocusToFirstNode()
     this.setFocusToFirstNode()
   }
   }
@@ -240,10 +224,11 @@ module.exports = class Dashboard extends Plugin {
       isHidden: true
       isHidden: true
     })
     })
 
 
-    // document.body.classList.remove('uppy-Dashboard-isOpen')
-    this.scrollBehaviour('enable')
+    if (!this.opts.disablePageScrollWhenModalOpen) {
+      document.body.classList.remove('uppy-Dashboard-isOpen')
+    }
+
     this.savedActiveElement.focus()
     this.savedActiveElement.focus()
-    // window.scrollTo(0, this.savedScrollPosition)
   }
   }
 
 
   isModalOpen () {
   isModalOpen () {

+ 1 - 2
src/scss/_dashboard.scss

@@ -9,9 +9,8 @@
 
 
 // Added to body to prevent the page from scrolling when Modal is open
 // Added to body to prevent the page from scrolling when Modal is open
 .uppy-Dashboard-isOpen {
 .uppy-Dashboard-isOpen {
-  width: 100%;
   overflow: hidden;
   overflow: hidden;
-  position: fixed;
+  height: 100vh;
 }
 }
 
 
 .uppy-Dashboard--modal .uppy-Dashboard-overlay {
 .uppy-Dashboard--modal .uppy-Dashboard-overlay {

+ 2 - 2
website/package.json

@@ -3,7 +3,7 @@
   "version": "0.0.1",
   "version": "0.0.1",
   "private": true,
   "private": true,
   "hexo": {
   "hexo": {
-    "version": "3.3.7"
+    "version": "3.5.0"
   },
   },
   "dependencies": {
   "dependencies": {
     "autoprefixer": "^7.2.5",
     "autoprefixer": "^7.2.5",
@@ -42,4 +42,4 @@
     "remark": "5.0.1",
     "remark": "5.0.1",
     "watchify": "^3.9.0"
     "watchify": "^3.9.0"
   }
   }
-}
+}