Skip to content

Commit 4397d2d

Browse files
committed
Refactor swipe.js
The variables have not been reassigned a value, so it's better to use "const" instead of "let", to prevent any unexpected behavior that may occur due to unintended assignment.
1 parent 19223b2 commit 4397d2d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/components/swipe.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function (Glide, Components, Events) {
2121
let swipeStartX = 0
2222
let swipeStartY = 0
2323
let disabled = false
24-
let capture = (supportsPassive) ? { passive: true } : false
24+
const capture = (supportsPassive) ? { passive: true } : false
2525

2626
const Swipe = {
2727
/**
@@ -43,7 +43,7 @@ export default function (Glide, Components, Events) {
4343
if (!disabled && !Glide.disabled) {
4444
this.disable()
4545

46-
let swipe = this.touches(event)
46+
const swipe = this.touches(event)
4747

4848
swipeSin = null
4949
swipeStartX = toInt(swipe.pageX)
@@ -65,14 +65,14 @@ export default function (Glide, Components, Events) {
6565
if (!Glide.disabled) {
6666
const { touchAngle, touchRatio, classes } = Glide.settings
6767

68-
let swipe = this.touches(event)
68+
const swipe = this.touches(event)
6969

70-
let subExSx = toInt(swipe.pageX) - swipeStartX
71-
let subEySy = toInt(swipe.pageY) - swipeStartY
72-
let powEX = Math.abs(subExSx << 2)
73-
let powEY = Math.abs(subEySy << 2)
74-
let swipeHypotenuse = Math.sqrt(powEX + powEY)
75-
let swipeCathetus = Math.sqrt(powEY)
70+
const subExSx = toInt(swipe.pageX) - swipeStartX
71+
const subEySy = toInt(swipe.pageY) - swipeStartY
72+
const powEX = Math.abs(subExSx << 2)
73+
const powEY = Math.abs(subEySy << 2)
74+
const swipeHypotenuse = Math.sqrt(powEX + powEY)
75+
const swipeCathetus = Math.sqrt(powEY)
7676

7777
swipeSin = Math.asin(swipeCathetus / swipeHypotenuse)
7878

@@ -100,11 +100,11 @@ export default function (Glide, Components, Events) {
100100
if (!Glide.disabled) {
101101
const { perSwipe, touchAngle, classes } = Glide.settings
102102

103-
let swipe = this.touches(event)
104-
let threshold = this.threshold(event)
103+
const swipe = this.touches(event)
104+
const threshold = this.threshold(event)
105105

106-
let swipeDistance = swipe.pageX - swipeStartX
107-
let swipeDeg = swipeSin * 180 / Math.PI
106+
const swipeDistance = swipe.pageX - swipeStartX
107+
const swipeDeg = swipeSin * 180 / Math.PI
108108

109109
this.enable()
110110

@@ -216,7 +216,7 @@ export default function (Glide, Components, Events) {
216216
* @return {Number}
217217
*/
218218
threshold (event) {
219-
let settings = Glide.settings
219+
const settings = Glide.settings
220220

221221
if (MOUSE_EVENTS.indexOf(event.type) > -1) {
222222
return settings.dragThreshold

0 commit comments

Comments
 (0)