Fix type errors
This commit is contained in:
parent
4cdb4bde6f
commit
358f2634ad
@ -2,30 +2,27 @@ export * from "./controllers.js";
|
|||||||
|
|
||||||
(function enableScrollPreservation() {
|
(function enableScrollPreservation() {
|
||||||
/* https://github.com/hotwired/turbo/issues/37#issuecomment-1422200868 */
|
/* https://github.com/hotwired/turbo/issues/37#issuecomment-1422200868 */
|
||||||
Turbo.scrollTop = 0;
|
let scrollTop = 0;
|
||||||
|
|
||||||
Turbo.shouldPreserveScroll = false;
|
let shouldPreserveScroll = false;
|
||||||
|
|
||||||
let shouldPreserveScroll = 0;
|
|
||||||
|
|
||||||
document.addEventListener("turbo:click", function (event) {
|
document.addEventListener("turbo:click", function (event) {
|
||||||
if (event.target.hasAttribute("data-turbo-preserve-scroll")) {
|
if ((event.target as HTMLDivElement).hasAttribute("data-turbo-preserve-scroll")) {
|
||||||
shouldPreserveScroll = true;
|
shouldPreserveScroll = true;
|
||||||
} else {
|
} else {
|
||||||
shouldPreserveScroll = false;
|
shouldPreserveScroll = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("turbo:visit", function (event) {
|
document.addEventListener("turbo:visit", function () {
|
||||||
if (shouldPreserveScroll) {
|
if (shouldPreserveScroll) {
|
||||||
Turbo.scrollTop = document.documentElement.scrollTop;
|
scrollTop = document.documentElement.scrollTop;
|
||||||
} else {
|
} else {
|
||||||
Turbo.scrollTop = 0;
|
scrollTop = 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addEventListener("turbo:visit", () => {
|
addEventListener("turbo:visit", () => {
|
||||||
Turbo.navigator.currentVisit.scrolled = true;
|
document.documentElement.scrollTop = scrollTop;
|
||||||
document.documentElement.scrollTop = Turbo.scrollTop;
|
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user