interaction js drag anddrop

Solutions on MaxInterview for interaction js drag anddrop by the best coders in the world

showing results for - "interaction js drag anddrop"
Viktoria
16 May 2018
1interact('.resize-drag')
2  .resizable({
3    // resize from all edges and corners
4    edges: { left: true, right: true, bottom: true, top: true },
5
6    listeners: {
7      move (event) {
8        var target = event.target
9        var x = (parseFloat(target.getAttribute('data-x')) || 0)
10        var y = (parseFloat(target.getAttribute('data-y')) || 0)
11
12        // update the element's style
13        target.style.width = event.rect.width + 'px'
14        target.style.height = event.rect.height + 'px'
15
16        // translate when resizing from top or left edges
17        x += event.deltaRect.left
18        y += event.deltaRect.top
19
20        target.style.webkitTransform = target.style.transform =
21          'translate(' + x + 'px,' + y + 'px)'
22
23        target.setAttribute('data-x', x)
24        target.setAttribute('data-y', y)
25        target.textContent = Math.round(event.rect.width) + '\u00D7' + Math.round(event.rect.height)
26      }
27    },
28    modifiers: [
29      // keep the edges inside the parent
30      interact.modifiers.restrictEdges({
31        outer: 'parent'
32      }),
33
34      // minimum size
35      interact.modifiers.restrictSize({
36        min: { width: 100, height: 100 }
37      })
38    ],
39
40    inertia: true
41  })
42  .draggable({
43    listeners: { move: window.dragMoveListener },
44    inertia: true,
45    modifiers: [
46      interact.modifiers.restrictRect({
47        restriction: 'parent',
48        endOnly: true
49      })
50    ]
51  })