perf(all): minify better by using arrow functions (#18730)

This commit is contained in:
Manu MA
2019-07-10 16:33:33 +02:00
committed by Brandy Carney
parent 8beeff2c52
commit 03c1d19e07
99 changed files with 653 additions and 679 deletions

View File

@ -1,26 +1,26 @@
import { Gesture, GestureDetail, createGesture } from './index';
export function createSwipeBackGesture(
export const createSwipeBackGesture = (
el: HTMLElement,
canStartHandler: () => boolean,
onStartHandler: () => void,
onMoveHandler: (step: number) => void,
onEndHandler: (shouldComplete: boolean, step: number, dur: number) => void,
): Gesture {
): Gesture => {
const win = el.ownerDocument!.defaultView!;
function canStart(detail: GestureDetail) {
const canStart = (detail: GestureDetail) => {
return detail.startX <= 50 && canStartHandler();
}
};
function onMove(detail: GestureDetail) {
const onMove = (detail: GestureDetail) => {
// set the transition animation's progress
const delta = detail.deltaX;
const stepValue = delta / win.innerWidth;
onMoveHandler(stepValue);
}
};
function onEnd(detail: GestureDetail) {
const onEnd = (detail: GestureDetail) => {
// the swipe back gesture has ended
const delta = detail.deltaX;
const width = win.innerWidth;
@ -38,7 +38,7 @@ export function createSwipeBackGesture(
realDur = Math.min(dur, 300);
}
onEndHandler(shouldComplete, stepValue, realDur);
}
};
return createGesture({
el,
@ -50,4 +50,4 @@ export function createSwipeBackGesture(
onMove,
onEnd
});
}
};