Skip to content

Commit 4797771

Browse files
committed
Clean up Opera setDragImage patch
Issue #1166
1 parent f2d2938 commit 4797771

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lib/codemirror.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,6 @@ window.CodeMirror = (function() {
169169
// Used for measuring wheel scrolling granularity
170170
d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
171171

172-
//opera setDragImage hack
173-
if (opera) {
174-
var img = elt('img');
175-
img.width = '1';
176-
img.height = '1';
177-
img.setAttribute('style','position:fixed; top:0; left:0; right:0');
178-
d.wrapper.appendChild(img);
179-
}
180-
181172
return d;
182173
}
183174

@@ -1621,9 +1612,17 @@ window.CodeMirror = (function() {
16211612

16221613
// Use dummy image instead of default browsers image.
16231614
// Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
1624-
var img = opera ? cm.display.wrapper.getElementsByTagName('img')[0] : elt('img');
1625-
if (e.dataTransfer.setDragImage && !safari)
1615+
if (e.dataTransfer.setDragImage && !safari) {
1616+
var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
1617+
if (opera) {
1618+
img.width = img.height = 1;
1619+
cm.display.wrapper.appendChild(img);
1620+
// Force a relayout, or Opera won't use our image for some obscure reason
1621+
img._top = img.offsetTop;
1622+
}
16261623
e.dataTransfer.setDragImage(img, 0, 0);
1624+
if (opera) img.parentNode.removeChild(img);
1625+
}
16271626
}
16281627

16291628
function setScrollTop(cm, val) {

0 commit comments

Comments
 (0)