Skip to content

Commit

Permalink
Fix cross-browser discrepancies (works on Chrome, Safari, FF, IE, bot…
Browse files Browse the repository at this point in the history
…h retina and not)

Fixes #4
  • Loading branch information
gaearon committed Oct 20, 2014
1 parent 8e803cd commit ac08bd5
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions modules/mixins/DragDropMixin.js
Expand Up @@ -23,10 +23,6 @@ function isSafari() {
return !!window.safari;
}

function isSafari8OrNewer() {
return isSafari() && parseInt(navigator.appVersion.match(/Version\/(\d+)\./)[1], 10) >= 8;
}

function shouldUseDragPreview(dragPreview) {
if (!dragPreview) {
return false;
Expand Down Expand Up @@ -58,9 +54,9 @@ function getDragImageOffset(containerNode, dragPreview, dragAnchors, e) {

// Work around @2x coordinate discrepancies in browsers
if (isFirefox()) {
offsetX = e.layerX * window.devicePixelRatio;
offsetY = e.layerY * window.devicePixelRatio;
} else if (isSafari8OrNewer()) {
offsetX = e.layerX;
offsetY = e.layerY;
} else if (isSafari()) {
previewHeight /= window.devicePixelRatio;
previewWidth /= window.devicePixelRatio;
}
Expand Down Expand Up @@ -88,7 +84,7 @@ function getDragImageOffset(containerNode, dragPreview, dragAnchors, e) {
}

// Work around Safari 8 positioning bug
if (isSafari8OrNewer()) {
if (isSafari()) {
// We'll have to wait for @3x to see if this is entirely correct
offsetY += (window.devicePixelRatio - 1) * previewHeight;
}
Expand All @@ -105,7 +101,7 @@ function calculateDragPreviewSize(desiredSize) {
height: desiredSize.height
};

if (isFirefox() || isSafari8OrNewer()) {
if (isFirefox() || isSafari()) {
size.width *= window.devicePixelRatio;
size.height *= window.devicePixelRatio;
}
Expand Down

0 comments on commit ac08bd5

Please sign in to comment.