question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Draggables "pile down" if constructed using v-for

See original GitHub issue

When I want to generate multiple draggables within one parent div using the v-for directive, the domain in which they can move in the y-direction piles up from the space in the y-direction, their predecessors are using.

So for example if the first element constructed using v-for has a size of (100, 100) and the second element is supposed to appear at (0,0), it appears at (0, 100) of the parent component but thinks, it is at (0, 0). As a consequence it can be moved down to y=(600-own height), even if the domain is only supposed to have a size of 500. Interestingly, this piling only occurs in the y-direction but not in the x-direction. I don’t know whether the issue becomes clear in my description, so here is some example code.

<template>
<div id="app" class="container">
  <div style="height: 500px; width: 500px; border: 1px solid red; position: relative;">
    <template v-for="element in elements">
      <vue-draggable-resizable :parent="true" :resizable="true" :x="element.x" :y="element.y" @dragstop="(x,y) => updateElementPosition(element, x, y)" style="border: 1px solid">
        <p>{{ element.text }}</p>
        <p>x-position: {{ element.x }} y-position: {{ element.y }}</p>
      </vue-draggable-resizable>
    </template>
  </div>
</div>
</template>

<script>
import VueDraggableResizable from 'vue-draggable-resizable'

export default {
  name: 'app',
  components: {
    VueDraggableResizable
  },
  data () {
    return {
      elements: [
        {
          text: 'I can be moved around freely within the parent',
          x: 0,
          y: 0
        },
        {
          text: 'My initial position is set to 0,0 but I appear below the previous element at 0, 200 and can be moved further down than the border of my parent',
          x: 0,
          y: 0
        },
        {
          text: 'I appear below the lower end of my predecessor. If the size of one of them is changed, I move accordingly without changing my coordinates',
          x: 0,
          y: 0
        }
      ]
    }
  },
  methods: {
    updateElementPosition (element, x, y) {
      element.x = x
      element.y = y
    }
  }
}
</script>

I’m using vue-draggable-resizable 1.2.2 and Vue 2.3.4

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
xlcrrcommented, Mar 12, 2021

I’m having the same problem with 2.3.0

@mauricius I am trying to use this to develop the OpenLitterAI, an open source trash detector

https://github.com/OpenLitterMap/openlittermap-web/blob/master/resources/js/views/admin/BoundingBox.vue

But I am unable to add more than 1 box to the page

Any suggestions?

I can give you access to our admin dashboard if you want to take a look at it

This is what it looks like

Screenshot 2021-03-12 at 21 08 03

The second box starts at position Y = 0, but is offset by the height of the previous box and I am unable to move it above the previous box

Hope you can help…

Thanks

0reactions
Lycon1996commented, Aug 31, 2021

这个问题解决了

OK fine , just add css ‘position:absolute’ for vdr

Read more comments on GitHub >

github_iconTop Results From Across the Web

JQuery Draggable and Resizeable over IFrames (Solution)
I found resizing/dragging many windows slows the UI down a lot, and as such I ended up hiding the iframes on start of...
Read more >
Stack/pile dropped elements - GSAP - GreenSock
Hi! I'm trying to build an interactive balancing scale where the user can drag and drop 12 coins in the bowls in order...
Read more >
An Essential Guide to JavaScript Drag and Drop By Examples
To drag an image, you simply hold the mouse button down and then move it. ... To make an element draggable, you add...
Read more >
Simple Drag Drop (Unity Tutorial for Beginners) - YouTube
Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=BGr-7GZJNXgLet's make a very simple Drag and Drop in Unity, ...
Read more >
Drag-and-Drop with jQuery: Your Essential Guide
Learn how to use jQuery, and the jQuery UI Draggable and ... Create the pile of shuffled cards var numbers = [ 1,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found