Browse Source

fix: 修复drag组件初始化定位被覆盖的问题

jerry 5 years ago
parent
commit
b7fbe79198
3 changed files with 3 additions and 5 deletions
  1. 1 1
      src/packages/drag/demo.vue
  2. 0 2
      src/packages/drag/drag.scss
  3. 2 2
      src/packages/drag/drag.vue

+ 1 - 1
src/packages/drag/demo.vue

@@ -9,7 +9,7 @@
     <nut-drag direction="x" :style="{ top: '200px', left: '8px' }">
       <div class="touch-dom">只能在X轴拖动</div>
     </nut-drag>
-    <nut-drag direction="y" :style="{ top: '200px', right: '8px' }">
+    <nut-drag direction="y" :style="{ top: '200px', right: '100px' }">
       <div class="touch-dom">只能在Y轴拖动</div>
     </nut-drag>
     <h4 :style="{ top: '250px' }">自动吸边</h4>

+ 0 - 2
src/packages/drag/drag.scss

@@ -1,8 +1,6 @@
 .nut-drag {
   position: fixed;
   display: inline-block;
-  top: 0;
-  right: 0;
   z-index: 9997 !important;
   width: fit-content;
   height: fit-content;

+ 2 - 2
src/packages/drag/drag.vue

@@ -72,12 +72,12 @@ export default {
       el.style.zIndex = this.zIndex;
       if (this.boundary.left) {
         el.style.left = this.boundary.left + 'px';
-      } else {
+      } else if (this.boundary.right) {
         el.style.right = this.boundary.right + 'px';
       }
       if (this.boundary.top) {
         el.style.top = this.boundary.top + 'px';
-      } else {
+      } else if (this.boundary.bottom) {
         el.style.bottom = this.boundary.bottom + 'px';
       }
     },