s/var/let/

This commit is contained in:
Simon Ser 2021-06-10 18:11:11 +02:00
parent 4db845a4b1
commit 8972130252
20 changed files with 481 additions and 479 deletions

View file

@ -1,6 +1,6 @@
import { html, Component } from "../lib/index.js";
var store = new Map();
let store = new Map();
export default class ScrollManager extends Component {
constructor(props) {
@ -10,18 +10,18 @@ export default class ScrollManager extends Component {
}
isAtBottom() {
var target = this.props.target.current;
let target = this.props.target.current;
return target.scrollTop >= target.scrollHeight - target.offsetHeight;
}
saveScrollPosition() {
var target = this.props.target.current;
let target = this.props.target.current;
var sticky = target.querySelectorAll(this.props.stickTo);
var stickToKey = null;
let sticky = target.querySelectorAll(this.props.stickTo);
let stickToKey = null;
if (!this.isAtBottom()) {
for (var i = 0; i < sticky.length; i++) {
var el = sticky[i];
for (let i = 0; i < sticky.length; i++) {
let el = sticky[i];
if (el.offsetTop >= target.scrollTop + target.offsetTop) {
stickToKey = el.dataset.key;
break;
@ -33,13 +33,13 @@ export default class ScrollManager extends Component {
}
restoreScrollPosition() {
var target = this.props.target.current;
let target = this.props.target.current;
var stickToKey = store.get(this.props.scrollKey);
let stickToKey = store.get(this.props.scrollKey);
if (!stickToKey) {
target.firstChild.scrollIntoView({ block: "end" });
} else {
var stickTo = target.querySelector("[data-key=\"" + stickToKey + "\"]");
let stickTo = target.querySelector("[data-key=\"" + stickToKey + "\"]");
if (stickTo) {
stickTo.scrollIntoView();
}