Browse Source

Allow dragging on iframes

iframes steal the events, so you cannot drop on an iframe. When re-arranging a list, it looks like nothing works when mouse is over an iframe. Setting pointer-events:none to the iframe fixes it, so on drag start - set pointer-events:none to all iframes, and on drop return everything to the way it was.
pull/1143/head
Oria 8 years ago committed by GitHub
parent
commit
7092dd27d7
  1. 15
      Sortable.js

15
Sortable.js

@ -55,6 +55,7 @@
moved,
iframe_stash,
root_iframes,
/** @const */
R_SPACE = /\s+/g,
@ -411,6 +412,16 @@
iframe_stash.appendChild(iframes[i]);
}
}
// stop iframes from stealing mouse events, to allow dragging on them
root_iframes = rootEl.querySelectorAll('iframe');
if (root_iframes && root_iframes.length)
{
for (var i = 0; i < root_iframes.length; i++)
{
root_iframes[i].sortable_pe = root_iframes[i].style['pointer-events'];
root_iframes[i].style['pointer-events'] = 'none';
}
}
// Delayed drag has been triggered
// we can re-enable the events: touchmove/mousemove
@ -917,6 +928,10 @@
}
iframe_stash = null;
}
// make iframes clickable again
for (var i = 0; i < root_iframes.length; i++)
root_iframes[i].style['pointer-events'] = root_iframes[i].sortable_pe;
root_iframes = [];
if (evt) {
if (moved) {

Loading…
Cancel
Save