Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion content_scripts/marks.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,20 @@ const Marks = {
},

getMarkString() {
let localScrollX = 0;
let localScrollY = 0;
if (globalThis.Scroller) {
const scrollableEl = Scroller.activeElement();
if (scrollableEl) {
localScrollX = scrollableEl.scrollLeft;
localScrollY = scrollableEl.scrollTop;
}
}
return JSON.stringify({
scrollX: globalThis.scrollX,
scrollY: globalThis.scrollY,
localScrollX,
localScrollY,
hash: globalThis.location.hash,
});
},
Expand Down Expand Up @@ -117,10 +128,19 @@ const Marks = {
if (markString != null) {
this.setPreviousPosition();
const position = JSON.parse(markString);
if (position.hash && (position.scrollX === 0) && (position.scrollY === 0)) {
if (position.hash && (position.scrollX === 0) && (position.scrollY === 0) && !position.localScrollX && !position.localScrollY) {
globalThis.location.hash = position.hash;
} else {
globalThis.scrollTo(position.scrollX, position.scrollY);
if ("localScrollX" in position) {
if (globalThis.Scroller) {
const scrollableEl = Scroller.activeElement();
if (scrollableEl) {
scrollableEl.scrollLeft = position.localScrollX;
scrollableEl.scrollTop = position.localScrollY;
}
}
}
}
this.showMessage("Jumped to local mark", keyChar);
} else {
Expand Down
8 changes: 8 additions & 0 deletions content_scripts/scroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,14 @@ const Scroller = {
}
}
},

activeElement() {
if (!activatedElement || !document.body.contains(activatedElement)) {
activatedElement = (getScrollingElement() && firstScrollableElement()) ||
getScrollingElement();
}
return activatedElement;
},
};

const getSpecialScrollingElement = function () {
Expand Down