|
@@ -5,11 +5,15 @@
|
|
|
return maxWidth;
|
|
|
return Math.floor(maxWidth / timeSteps) * timeKey;
|
|
|
}
|
|
|
+
|
|
|
+ console.log("scrollY", window.scrollY);
|
|
|
|
|
|
- const elem = document.querySelector("#sliderBar");
|
|
|
- const rect = elem.getBoundingClientRect();
|
|
|
+ const elem = document.querySelector("tp-yt-paper-progress#sliderBar");
|
|
|
+ const rect = getOffset(elem);
|
|
|
const x = getX(1, rect.width);
|
|
|
- const y = (rect.top + rect.bottom) / 2;
|
|
|
+ const y = rect.top - rect.height / 2;
|
|
|
+
|
|
|
+ console.log(x, y, rect);
|
|
|
|
|
|
const evt = new MouseEvent("mousedown", {
|
|
|
clientX: x,
|
|
@@ -19,5 +23,18 @@
|
|
|
view: window,
|
|
|
});
|
|
|
|
|
|
- document.body.dispatchEvent(evt);
|
|
|
+ elem.dispatchEvent(evt);
|
|
|
+
|
|
|
+ function getOffset(el) {
|
|
|
+ var _x = 0;
|
|
|
+ var _y = 0;
|
|
|
+ const rect = el.getBoundingClientRect();
|
|
|
+ console.log("rect", rect);
|
|
|
+ while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
|
|
|
+ _x += el.offsetLeft - el.scrollLeft;
|
|
|
+ _y += el.offsetTop - el.scrollTop;
|
|
|
+ el = el.offsetParent;
|
|
|
+ }
|
|
|
+ return { top: _y, left: _x, width: rect.width, height: rect.height };
|
|
|
+ }
|
|
|
})();
|