It makes compatible with iframes.
This commit is contained in:
parent
d4ec7fca6d
commit
6ac02fae2b
@ -93,6 +93,7 @@
|
|||||||
|
|
||||||
var isRtl = $this.css('direction') === "rtl";
|
var isRtl = $this.css('direction') === "rtl";
|
||||||
var eventClassName = getEventClassName();
|
var eventClassName = getEventClassName();
|
||||||
|
var ownerDocument = this.ownerDocument || document;
|
||||||
|
|
||||||
var $scrollbarXRail = $("<div class='ps-scrollbar-x-rail'>").appendTo($this);
|
var $scrollbarXRail = $("<div class='ps-scrollbar-x-rail'>").appendTo($this);
|
||||||
var $scrollbarX = $("<div class='ps-scrollbar-x'>").appendTo($scrollbarXRail);
|
var $scrollbarX = $("<div class='ps-scrollbar-x'>").appendTo($scrollbarXRail);
|
||||||
@ -265,7 +266,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind('mousemove' + eventClassName, function (e) {
|
$(ownerDocument).bind('mousemove' + eventClassName, function (e) {
|
||||||
if ($scrollbarXRail.hasClass('in-scrolling')) {
|
if ($scrollbarXRail.hasClass('in-scrolling')) {
|
||||||
updateScrollLeft(currentLeft, e.pageX - currentPageX);
|
updateScrollLeft(currentLeft, e.pageX - currentPageX);
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
@ -274,7 +275,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind('mouseup' + eventClassName, function (e) {
|
$(ownerDocument).bind('mouseup' + eventClassName, function (e) {
|
||||||
if ($scrollbarXRail.hasClass('in-scrolling')) {
|
if ($scrollbarXRail.hasClass('in-scrolling')) {
|
||||||
$scrollbarXRail.removeClass('in-scrolling');
|
$scrollbarXRail.removeClass('in-scrolling');
|
||||||
}
|
}
|
||||||
@ -296,7 +297,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind('mousemove' + eventClassName, function (e) {
|
$(ownerDocument).bind('mousemove' + eventClassName, function (e) {
|
||||||
if ($scrollbarYRail.hasClass('in-scrolling')) {
|
if ($scrollbarYRail.hasClass('in-scrolling')) {
|
||||||
updateScrollTop(currentTop, e.pageY - currentPageY);
|
updateScrollTop(currentTop, e.pageY - currentPageY);
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
@ -305,7 +306,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind('mouseup' + eventClassName, function (e) {
|
$(ownerDocument).bind('mouseup' + eventClassName, function (e) {
|
||||||
if ($scrollbarYRail.hasClass('in-scrolling')) {
|
if ($scrollbarYRail.hasClass('in-scrolling')) {
|
||||||
$scrollbarYRail.removeClass('in-scrolling');
|
$scrollbarYRail.removeClass('in-scrolling');
|
||||||
}
|
}
|
||||||
@ -425,7 +426,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
var shouldPrevent = false;
|
var shouldPrevent = false;
|
||||||
$(document).bind('keydown' + eventClassName, function (e) {
|
$(ownerDocument).bind('keydown' + eventClassName, function (e) {
|
||||||
if (e.isDefaultPrevented && e.isDefaultPrevented()) {
|
if (e.isDefaultPrevented && e.isDefaultPrevented()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -434,7 +435,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var activeElement = document.activeElement;
|
var activeElement = document.activeElement ? document.activeElement : ownerDocument.activeElement;
|
||||||
// go deeper if element is a webcomponent
|
// go deeper if element is a webcomponent
|
||||||
while (activeElement.shadowRoot) {
|
while (activeElement.shadowRoot) {
|
||||||
activeElement = activeElement.shadowRoot.activeElement;
|
activeElement = activeElement.shadowRoot.activeElement;
|
||||||
@ -642,7 +643,7 @@
|
|||||||
function destroy() {
|
function destroy() {
|
||||||
$this.unbind(eventClassName);
|
$this.unbind(eventClassName);
|
||||||
$(window).unbind(eventClassName);
|
$(window).unbind(eventClassName);
|
||||||
$(document).unbind(eventClassName);
|
$(ownerDocument).unbind(eventClassName);
|
||||||
$this.data('perfect-scrollbar', null);
|
$this.data('perfect-scrollbar', null);
|
||||||
$this.data('perfect-scrollbar-update', null);
|
$this.data('perfect-scrollbar-update', null);
|
||||||
$this.data('perfect-scrollbar-destroy', null);
|
$this.data('perfect-scrollbar-destroy', null);
|
||||||
|
Loading…
Reference in New Issue
Block a user