1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-11 17:51:01 +00:00

Replace a bunch of let with const

According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const

> Many style guides (including MDN's) recommend using const over let whenever a
variable is not reassigned in its scope. This makes the intent clear that a
variable's type (or value, in the case of a primitive) can never change.
This commit is contained in:
jvoisin 2024-03-20 23:59:37 +01:00 committed by Frédéric Guillot
parent fc4bdf3ab0
commit beb8c80787
6 changed files with 41 additions and 44 deletions

View file

@ -15,8 +15,8 @@ class TouchHandler {
calculateDistance() {
if (this.touch.start.x >= -1 && this.touch.move.x >= -1) {
let horizontalDistance = Math.abs(this.touch.move.x - this.touch.start.x);
let verticalDistance = Math.abs(this.touch.move.y - this.touch.start.y);
const horizontalDistance = Math.abs(this.touch.move.x - this.touch.start.x);
const verticalDistance = Math.abs(this.touch.move.y - this.touch.start.y);
if (horizontalDistance > 30 && verticalDistance < 70 || this.touch.moved) {
return this.touch.move.x - this.touch.start.x;
@ -54,8 +54,8 @@ class TouchHandler {
this.touch.move.x = event.touches[0].clientX;
this.touch.move.y = event.touches[0].clientY;
let distance = this.calculateDistance();
let absDistance = Math.abs(distance);
const distance = this.calculateDistance();
const absDistance = Math.abs(distance);
if (absDistance > 0) {
this.touch.moved = true;
@ -78,7 +78,7 @@ class TouchHandler {
}
if (this.touch.element !== null) {
let absDistance = Math.abs(this.calculateDistance());
const absDistance = Math.abs(this.calculateDistance());
if (absDistance > 75) {
toggleEntryStatus(this.touch.element);
@ -118,9 +118,9 @@ class TouchHandler {
return;
}
let distance = this.calculateDistance();
let absDistance = Math.abs(distance);
let now = Date.now();
const distance = this.calculateDistance();
const absDistance = Math.abs(distance);
const now = Date.now();
if (now - this.touch.time <= 1000 && absDistance > 75) {
if (distance > 0) {
@ -138,10 +138,10 @@ class TouchHandler {
return;
}
let now = Date.now();
const now = Date.now();
if (this.touch.start.x !== -1 && now - this.touch.time <= 200) {
let innerWidthHalf = window.innerWidth / 2;
const innerWidthHalf = window.innerWidth / 2;
if (this.touch.start.x >= innerWidthHalf && event.changedTouches[0].clientX >= innerWidthHalf) {
goToPage("next");
@ -158,19 +158,16 @@ class TouchHandler {
}
listen() {
let hasPassiveOption = DomHelper.hasPassiveEventListenerOption();
const hasPassiveOption = DomHelper.hasPassiveEventListenerOption();
let elements = document.querySelectorAll(".entry-swipe");
elements.forEach((element) => {
document.querySelectorAll(".entry-swipe").forEach((element) => {
element.addEventListener("touchstart", (e) => this.onItemTouchStart(e), hasPassiveOption ? { passive: true } : false);
element.addEventListener("touchmove", (e) => this.onItemTouchMove(e), hasPassiveOption ? { passive: false } : false);
element.addEventListener("touchend", (e) => this.onItemTouchEnd(e), hasPassiveOption ? { passive: true } : false);
element.addEventListener("touchcancel", () => this.reset(), hasPassiveOption ? { passive: true } : false);
});
let element = document.querySelector(".entry-content");
const element = document.querySelector(".entry-content");
if (element) {
if (element.classList.contains("gesture-nav-tap")) {
element.addEventListener("touchend", (e) => this.onTapEnd(e), hasPassiveOption ? { passive: true } : false);