1 line
7.5 KiB
Plaintext
1 line
7.5 KiB
Plaintext
{"version":3,"sources":["FlingGestureHandler.ts"],"names":["FlingGestureHandler","DraggingGestureHandler","name","NativeGestureClass","Hammer","Swipe","onGestureActivated","event","sendEvent","eventType","INPUT_MOVE","isFinal","isFirst","isGestureRunning","hasGestureFailed","INPUT_END","onRawEvent","ev","setTimeout","cancelEvent","gesture","hammer","get","options","enable","onStart","getHammerConfig","pointers","config","numberOfPointers","direction","getDirection","getTargetDirections","directions","Direction","RIGHT","push","DIRECTION_RIGHT","LEFT","DIRECTION_LEFT","UP","DIRECTION_UP","DOWN","DIRECTION_DOWN","getConfig","DIRECTION_HORIZONTAL","DIRECTION_VERTICAL","Set","length","DIRECTION_NONE","DIRECTION_ALL","isGestureEnabledForEvent","_recognizer","maxPointers","pointerLength","validPointerCount","failed","success","updateGestureConfig","props","GesturePropError"],"mappings":";;;;;;;AAEA;;AAEA;;AACA;;AACA;;AACA;;;;AAPA;;AACA;AASA,MAAMA,mBAAN,SAAkCC,+BAAlC,CAAyD;AAC/C,MAAJC,IAAI,GAAG;AACT,WAAO,OAAP;AACD;;AAEqB,MAAlBC,kBAAkB,GAAG;AACvB,WAAOC,kBAAOC,KAAd;AACD;;AAEDC,EAAAA,kBAAkB,CAACC,KAAD,EAAwB;AACxC,SAAKC,SAAL,CAAe,EACb,GAAGD,KADU;AAEbE,MAAAA,SAAS,EAAEL,kBAAOM,UAFL;AAGbC,MAAAA,OAAO,EAAE,KAHI;AAIbC,MAAAA,OAAO,EAAE;AAJI,KAAf;AAMA,SAAKC,gBAAL,GAAwB,KAAxB;AACA,SAAKC,gBAAL,GAAwB,KAAxB;AACA,SAAKN,SAAL,CAAe,EACb,GAAGD,KADU;AAEbE,MAAAA,SAAS,EAAEL,kBAAOW,SAFL;AAGbJ,MAAAA,OAAO,EAAE;AAHI,KAAf;AAKD;;AAEDK,EAAAA,UAAU,CAACC,EAAD,EAAqB;AAC7B,UAAMD,UAAN,CAAiBC,EAAjB;;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AP;AACD;;AACD,WAAO;AAAEC,MAAAA,OAAO,EAAEF;AAAX,KAAP;AACD;;AAEDG,EAAAA,mBAAmB,CAAC;AAAE7B,IAAAA,gBAAgB,GAAG,CAArB;AAAwBC,IAAAA,SAAxB;AAAmC,OAAG6B;AAAtC,GAAD,EAAqD;AACtE,QAAI,kBAAM7B,SAAN,KAAoB,OAAOA,SAAP,KAAqB,QAA7C,EAAuD;AACrD,YAAM,IAAI8B,wBAAJ,CAAqB,WAArB,EAAkC9B,SAAlC,EAA6C,QAA7C,CAAN;AACD;;AACD,WAAO,MAAM4B,mBAAN,CAA0B;AAC/B7B,MAAAA,gBAD+B;AAE/BC,MAAAA,SAF+B;AAG/B,SAAG6B;AAH4B,KAA1B,CAAP;AAKD;;AAxHsD;;eA2H1C3D,mB","sourcesContent":["/* eslint-disable eslint-comments/no-unlimited-disable */\n/* eslint-disable */\nimport Hammer from '@egjs/hammerjs';\n\nimport { Direction } from './constants';\nimport { GesturePropError } from './Errors';\nimport DraggingGestureHandler from './DraggingGestureHandler';\nimport { isnan } from './utils';\nimport { HammerInputExt } from './GestureHandler';\n\nclass FlingGestureHandler extends DraggingGestureHandler {\n get name() {\n return 'swipe';\n }\n\n get NativeGestureClass() {\n return Hammer.Swipe;\n }\n\n onGestureActivated(event: HammerInputExt) {\n this.sendEvent({\n ...event,\n eventType: Hammer.INPUT_MOVE,\n isFinal: false,\n isFirst: true,\n });\n this.isGestureRunning = false;\n this.hasGestureFailed = false;\n this.sendEvent({\n ...event,\n eventType: Hammer.INPUT_END,\n isFinal: true,\n });\n }\n\n onRawEvent(ev: HammerInputExt) {\n super.onRawEvent(ev);\n if (this.hasGestureFailed) {\n return;\n }\n // Hammer doesn't send a `cancel` event for taps.\n // Manually fail the event.\n if (ev.isFinal) {\n setTimeout(() => {\n if (this.isGestureRunning) {\n this.cancelEvent(ev);\n }\n });\n } else if (!this.hasGestureFailed && !this.isGestureRunning) {\n // Tap Gesture start event\n const gesture = this.hammer!.get(this.name);\n // @ts-ignore FIXME(TS)\n if (gesture.options.enable(gesture, ev)) {\n this.onStart(ev);\n this.sendEvent(ev);\n }\n }\n }\n\n getHammerConfig() {\n return {\n // @ts-ignore FIXME(TS)\n pointers: this.config.numberOfPointers,\n direction: this.getDirection(),\n };\n }\n\n getTargetDirections(direction: number) {\n const directions = [];\n if (direction & Direction.RIGHT) {\n directions.push(Hammer.DIRECTION_RIGHT);\n }\n if (direction & Direction.LEFT) {\n directions.push(Hammer.DIRECTION_LEFT);\n }\n if (direction & Direction.UP) {\n directions.push(Hammer.DIRECTION_UP);\n }\n if (direction & Direction.DOWN) {\n directions.push(Hammer.DIRECTION_DOWN);\n }\n // const hammerDirection = directions.reduce((a, b) => a | b, 0);\n return directions;\n }\n\n getDirection() {\n // @ts-ignore FIXME(TS)\n const { direction } = this.getConfig();\n\n let directions = [];\n if (direction & Direction.RIGHT) {\n directions.push(Hammer.DIRECTION_HORIZONTAL);\n }\n if (direction & Direction.LEFT) {\n directions.push(Hammer.DIRECTION_HORIZONTAL);\n }\n if (direction & Direction.UP) {\n directions.push(Hammer.DIRECTION_VERTICAL);\n }\n if (direction & Direction.DOWN) {\n directions.push(Hammer.DIRECTION_VERTICAL);\n }\n directions = [...new Set(directions)];\n\n if (directions.length === 0) return Hammer.DIRECTION_NONE;\n if (directions.length === 1) return directions[0];\n return Hammer.DIRECTION_ALL;\n }\n\n isGestureEnabledForEvent(\n { numberOfPointers }: any,\n _recognizer: any,\n { maxPointers: pointerLength }: any\n ) {\n const validPointerCount = pointerLength === numberOfPointers;\n if (!validPointerCount && this.isGestureRunning) {\n return { failed: true };\n }\n return { success: validPointerCount };\n }\n\n updateGestureConfig({ numberOfPointers = 1, direction, ...props }: any) {\n if (isnan(direction) || typeof direction !== 'number') {\n throw new GesturePropError('direction', direction, 'number');\n }\n return super.updateGestureConfig({\n numberOfPointers,\n direction,\n ...props,\n });\n }\n}\n\nexport default FlingGestureHandler;\n"]} |