refactor(zoomscroll): use layerX/Y instead more sophisticated solution.
As long as we use a container with relative positioning this should work. close #83
This commit is contained in:
parent
75402fe277
commit
a5668bfac7
|
@ -56,8 +56,8 @@ function ZoomScroll(events, canvas) {
|
||||||
// Gecko Browser should use _offsetX
|
// Gecko Browser should use _offsetX
|
||||||
if(!event.originalEvent.offsetX) {
|
if(!event.originalEvent.offsetX) {
|
||||||
offset = {
|
offset = {
|
||||||
x: event.originalEvent._offsetX,
|
x: event.originalEvent.layerX,
|
||||||
y: event.originalEvent._offsetY
|
y: event.originalEvent.layerY
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
offset = {
|
offset = {
|
||||||
|
@ -88,30 +88,3 @@ ZoomScroll.$inject = [ 'eventBus', 'canvas' ];
|
||||||
|
|
||||||
module.exports = ZoomScroll;
|
module.exports = ZoomScroll;
|
||||||
|
|
||||||
// Thx to https://bugzilla.mozilla.org/show_bug.cgi?id=69787#c37
|
|
||||||
// for providing a work around for missing offsetX in Gecko
|
|
||||||
Object.defineProperties(MouseEvent.prototype, {
|
|
||||||
_offsetRelativeElement: {
|
|
||||||
get: function() {
|
|
||||||
var element = this.target;
|
|
||||||
while (['block', 'inline-block', 'list-item', 'table', 'inline-table', 'table-caption',
|
|
||||||
'table-column', 'table-colgroup', 'table-header-group', 'table-row-group', 'table-footer-group',
|
|
||||||
'table-row', 'table-cell'].indexOf(window.getComputedStyle(element).display) === -1) {
|
|
||||||
|
|
||||||
element = element.parentNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
return element;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_offsetX: {
|
|
||||||
get: function() {
|
|
||||||
return this.clientX - this._offsetRelativeElement.getBoundingClientRect().left;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_offsetY: {
|
|
||||||
get: function() {
|
|
||||||
return this.clientY - this._offsetRelativeElement.getBoundingClientRect().top;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
Loading…
Reference in New Issue