Skip to content

Commit

Permalink
fixed drag bug in safari
Browse files Browse the repository at this point in the history
  • Loading branch information
easylogic committed Sep 15, 2018
1 parent 83b6400 commit f3816af
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
15 changes: 13 additions & 2 deletions addon/codemirror-colorpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5684,9 +5684,10 @@ var Dom = function () {
key: 'offset',
value: function offset() {
var rect = this.el.getBoundingClientRect();

return {
top: rect.top + document.documentElement.scrollTop,
left: rect.left + document.documentElement.scrollLeft
top: rect.top + Dom.getScrollTop(),
left: rect.left + Dom.getScrollLeft()
};
}
}, {
Expand Down Expand Up @@ -5859,6 +5860,16 @@ var Dom = function () {

return this;
}
}], [{
key: 'getScrollTop',
value: function getScrollTop() {
return Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop);
}
}, {
key: 'getScrollLeft',
value: function getScrollLeft() {
return Math.max(window.pageXOffset, document.documentElement.scrollLeft, document.body.scrollLeft);
}
}]);
return Dom;
}();
Expand Down
15 changes: 13 additions & 2 deletions dist/codemirror-colorpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5817,9 +5817,10 @@ var Dom = function () {
key: 'offset',
value: function offset() {
var rect = this.el.getBoundingClientRect();

return {
top: rect.top + document.documentElement.scrollTop,
left: rect.left + document.documentElement.scrollLeft
top: rect.top + Dom.getScrollTop(),
left: rect.left + Dom.getScrollLeft()
};
}
}, {
Expand Down Expand Up @@ -5992,6 +5993,16 @@ var Dom = function () {

return this;
}
}], [{
key: 'getScrollTop',
value: function getScrollTop() {
return Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop);
}
}, {
key: 'getScrollLeft',
value: function getScrollLeft() {
return Math.max(window.pageXOffset, document.documentElement.scrollLeft, document.body.scrollLeft);
}
}]);
return Dom;
}();
Expand Down
2 changes: 1 addition & 1 deletion dist/codemirror-colorpicker.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codemirror-colorpicker",
"version": "1.9.31",
"version": "1.9.32",
"description": "simple colorpicker used anywhere",
"main": "./dist/codemirror-colorpicker.js",
"scripts": {
Expand Down
12 changes: 10 additions & 2 deletions src/util/Dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ export default class Dom {
}
}

static getScrollTop () {
return Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop)
}

static getScrollLeft () {
return Math.max(window.pageXOffset, document.documentElement.scrollLeft, document.body.scrollLeft)
}

attr (key, value) {
if (arguments.length == 1) {
Expand Down Expand Up @@ -178,9 +185,10 @@ export default class Dom {

offset () {
var rect = this.el.getBoundingClientRect();

return {
top: rect.top + document.documentElement.scrollTop,
left: rect.left + document.documentElement.scrollLeft
top: rect.top + Dom.getScrollTop(),
left: rect.left + Dom.getScrollLeft()
};
}

Expand Down

0 comments on commit f3816af

Please sign in to comment.