Bug 1267403 - calculate spectrum element offset using getBoundingClientRect
MozReview-Commit-ID: 5dYyVU9BpHs
--- a/devtools/client/shared/widgets/Spectrum.js
+++ b/devtools/client/shared/widgets/Spectrum.js
@@ -128,28 +128,17 @@ Spectrum.rgbToHsv = function (r, g, b, a
case b: h = (r - g) / d + 4; break;
}
h /= 6;
}
return [h, s, v, a];
};
Spectrum.getOffset = function (el) {
- let curleft = 0, curtop = 0;
- if (el.offsetParent) {
- while (el) {
- curleft += el.offsetLeft;
- curtop += el.offsetTop;
- el = el.offsetParent;
- }
- }
- return {
- left: curleft,
- top: curtop
- };
+ return el.getBoundingClientRect();
};
Spectrum.draggable = function (element, onmove, onstart, onstop) {
onmove = onmove || function () {};
onstart = onstart || function () {};
onstop = onstop || function () {};
let doc = element.ownerDocument;