mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-02-07 18:39:23 +03:00
Fixed drag release outside of iframe when the iframe is on the same domain.
This commit is contained in:
parent
92be395d66
commit
703f922ed8
@ -1367,6 +1367,14 @@
|
|||||||
eventParams = getCaptureEventParams( tracker, $.MouseTracker.havePointerEvents ? 'pointerevent' : pointerType );
|
eventParams = getCaptureEventParams( tracker, $.MouseTracker.havePointerEvents ? 'pointerevent' : pointerType );
|
||||||
// We emulate mouse capture by hanging listeners on the document object.
|
// We emulate mouse capture by hanging listeners on the document object.
|
||||||
// (Note we listen on the capture phase so the captured handlers will get called first)
|
// (Note we listen on the capture phase so the captured handlers will get called first)
|
||||||
|
if (isInIframe() && canAccessEvents(window.top)) {
|
||||||
|
$.addEvent(
|
||||||
|
window.top,
|
||||||
|
eventParams.upName,
|
||||||
|
eventParams.upHandler,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
$.addEvent(
|
$.addEvent(
|
||||||
$.MouseTracker.captureElement,
|
$.MouseTracker.captureElement,
|
||||||
eventParams.upName,
|
eventParams.upName,
|
||||||
@ -1402,6 +1410,14 @@
|
|||||||
eventParams = getCaptureEventParams( tracker, $.MouseTracker.havePointerEvents ? 'pointerevent' : pointerType );
|
eventParams = getCaptureEventParams( tracker, $.MouseTracker.havePointerEvents ? 'pointerevent' : pointerType );
|
||||||
// We emulate mouse capture by hanging listeners on the document object.
|
// We emulate mouse capture by hanging listeners on the document object.
|
||||||
// (Note we listen on the capture phase so the captured handlers will get called first)
|
// (Note we listen on the capture phase so the captured handlers will get called first)
|
||||||
|
if (isInIframe() && canAccessEvents(window.top)) {
|
||||||
|
$.removeEvent(
|
||||||
|
window.top,
|
||||||
|
eventParams.upName,
|
||||||
|
eventParams.upHandler,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
$.removeEvent(
|
$.removeEvent(
|
||||||
$.MouseTracker.captureElement,
|
$.MouseTracker.captureElement,
|
||||||
eventParams.moveName,
|
eventParams.moveName,
|
||||||
@ -3248,5 +3264,33 @@
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
* @returns {Boolean} True if inside an iframe, otherwise false.
|
||||||
|
*/
|
||||||
|
function isInIframe () {
|
||||||
|
try {
|
||||||
|
return window.self !== window.top;
|
||||||
|
} catch (e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @private
|
||||||
|
* @inner
|
||||||
|
* @returns {Boolean} True if the target has access rights to events, otherwise false.
|
||||||
|
*/
|
||||||
|
function canAccessEvents (target) {
|
||||||
|
try {
|
||||||
|
return target.addEventListener && target.removeEventListener;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} ( OpenSeadragon ) );
|
} ( OpenSeadragon ) );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user