diff options
author | bobzel <zzzman@gmail.com> | 2024-04-29 23:00:22 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-04-29 23:00:22 -0400 |
commit | f6a741f38a33bdb30b3a1d88215656dcd3d0712d (patch) | |
tree | df88320222c743d26f2b1341c1489671277baec9 /src/ClientUtils.ts | |
parent | ab873e90112f2cac204a57a1b405cc241f7e8381 (diff) |
eslint fixes.
Diffstat (limited to 'src/ClientUtils.ts')
-rw-r--r-- | src/ClientUtils.ts | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/ClientUtils.ts b/src/ClientUtils.ts index 402f6613a..8011a1928 100644 --- a/src/ClientUtils.ts +++ b/src/ClientUtils.ts @@ -400,7 +400,7 @@ const easeFunc = (transition: 'ease' | 'linear' | undefined, currentTime: number export function smoothScroll(duration: number, element: HTMLElement | HTMLElement[], to: number, transition: 'ease' | 'linear' | undefined, stopper?: () => void) { stopper?.(); const elements = element instanceof HTMLElement ? [element] : element; - const starts = elements.map(element => element.scrollTop); + const starts = elements.map(ele => ele.scrollTop); const startDate = new Date().getTime(); let _stop = false; const stop = () => { @@ -409,15 +409,15 @@ export function smoothScroll(duration: number, element: HTMLElement | HTMLElemen const animateScroll = () => { const currentDate = new Date().getTime(); const currentTime = currentDate - startDate; - const setScrollTop = (element: HTMLElement, value: number) => { - element.scrollTop = value; + const setScrollTop = (ele: HTMLElement, value: number) => { + ele.scrollTop = value; }; if (!_stop) { if (currentTime < duration) { - elements.forEach((element, i) => currentTime && setScrollTop(element, easeFunc(transition, Math.min(currentTime, duration), starts[i], to - starts[i], duration))); + elements.forEach((ele, i) => currentTime && setScrollTop(ele, easeFunc(transition, Math.min(currentTime, duration), starts[i], to - starts[i], duration))); requestAnimationFrame(animateScroll); } else { - elements.forEach(element => setScrollTop(element, to)); + elements.forEach(ele => setScrollTop(ele, to)); } } }; @@ -427,21 +427,21 @@ export function smoothScroll(duration: number, element: HTMLElement | HTMLElemen export function smoothScrollHorizontal(duration: number, element: HTMLElement | HTMLElement[], to: number) { const elements = element instanceof HTMLElement ? [element] : element; - const starts = elements.map(element => element.scrollLeft); + const starts = elements.map(ele => ele.scrollLeft); const startDate = new Date().getTime(); const animateScroll = () => { const currentDate = new Date().getTime(); const currentTime = currentDate - startDate; - elements.forEach((element, i) => { - element.scrollLeft = easeFunc('ease', currentTime, starts[i], to - starts[i], duration); + elements.forEach((ele, i) => { + ele.scrollLeft = easeFunc('ease', currentTime, starts[i], to - starts[i], duration); }); if (currentTime < duration) { requestAnimationFrame(animateScroll); } else { - elements.forEach(element => { - element.scrollLeft = to; + elements.forEach(ele => { + ele.scrollLeft = to; }); } }; @@ -586,26 +586,26 @@ export function setupMoveUpEvents( targetAny._noClick = false; let moving = false; - const _moveEvent = (e: PointerEvent): void => { - if (moving || Math.abs(e.clientX - (target as any)._downX) > ClientUtils.DRAG_THRESHOLD || Math.abs(e.clientY - (target as any)._downY) > ClientUtils.DRAG_THRESHOLD) { + const _moveEvent = (moveEv: PointerEvent): void => { + if (moving || Math.abs(moveEv.clientX - (target as any)._downX) > ClientUtils.DRAG_THRESHOLD || Math.abs(moveEv.clientY - (target as any)._downY) > ClientUtils.DRAG_THRESHOLD) { moving = true; if ((target as any)._doubleTime) { clearTimeout((target as any)._doubleTime); targetAny._doubleTime = undefined; } - if (moveEvent(e, [(target as any)._downX, (target as any)._downY], [e.clientX - (target as any)._lastX, e.clientY - (target as any)._lastY])) { + if (moveEvent(moveEv, [(target as any)._downX, (target as any)._downY], [moveEv.clientX - (target as any)._lastX, moveEv.clientY - (target as any)._lastY])) { document.removeEventListener('pointermove', _moveEvent); // eslint-disable-next-line no-use-before-define document.removeEventListener('pointerup', _upEvent); } } - targetAny._lastX = e.clientX; - targetAny._lastY = e.clientY; - stopMovePropagation && e.stopPropagation(); + targetAny._lastX = moveEv.clientX; + targetAny._lastY = moveEv.clientY; + stopMovePropagation && moveEv.stopPropagation(); }; - const _upEvent = (e: PointerEvent): void => { - const isClick = Math.abs(e.clientX - targetAny._downX) < 4 && Math.abs(e.clientY - targetAny._downY) < 4; - upEvent(e, [e.clientX - targetAny._downX, e.clientY - targetAny._downY], isClick); + const _upEvent = (upEv: PointerEvent): void => { + const isClick = Math.abs(upEv.clientX - targetAny._downX) < 4 && Math.abs(upEv.clientY - targetAny._downY) < 4; + upEvent(upEv, [upEv.clientX - targetAny._downX, upEv.clientY - targetAny._downY], isClick); if (isClick) { if (!targetAny._doubleTime && noDoubleTapTimeout) { targetAny._doubleTime = setTimeout(() => { @@ -617,13 +617,13 @@ export function setupMoveUpEvents( clearTimeout(targetAny._doubleTime); targetAny._doubleTime = undefined; } - targetAny._noClick = clickEvent(e, targetAny._doubleTap); + targetAny._noClick = clickEvent(upEv, targetAny._doubleTap); } document.removeEventListener('pointermove', _moveEvent); document.removeEventListener('pointerup', _upEvent, true); }; - const _clickEvent = (e: MouseEvent): void => { - if ((target as any)._noClick) e.stopPropagation(); + const _clickEvent = (clickev: MouseEvent): void => { + if ((target as any)._noClick) clickev.stopPropagation(); document.removeEventListener('click', _clickEvent, true); }; if (stopPropagation) { |