a zip code crypto-currency system good for red ONLY

swipe-back.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { swipeShouldReset } from '../util/util';
  2. import { GESTURE_GO_BACK_SWIPE, GESTURE_PRIORITY_GO_BACK_SWIPE } from '../gestures/gesture-controller';
  3. import { SlideEdgeGesture } from '../gestures/slide-edge-gesture';
  4. /**
  5. * @hidden
  6. */
  7. export class SwipeBackGesture extends SlideEdgeGesture {
  8. constructor(plt, _nav, gestureCtlr, domCtrl) {
  9. super(plt, plt.doc().body, {
  10. direction: 'x',
  11. edge: 'start',
  12. maxEdgeStart: 75,
  13. threshold: 5,
  14. zone: false,
  15. domController: domCtrl,
  16. gesture: gestureCtlr.createGesture({
  17. name: GESTURE_GO_BACK_SWIPE,
  18. priority: GESTURE_PRIORITY_GO_BACK_SWIPE,
  19. disableScroll: true
  20. })
  21. });
  22. this._nav = _nav;
  23. }
  24. canStart(ev) {
  25. // the gesture swipe angle must be mainly horizontal and the
  26. // gesture distance would be relatively short for a swipe back
  27. // and swipe back must be possible on this nav controller
  28. return (this._nav.canSwipeBack() &&
  29. super.canStart(ev));
  30. }
  31. onSlideBeforeStart(_ev) {
  32. this._nav.swipeBackStart();
  33. }
  34. onSlide(slide, ev) {
  35. ev.preventDefault();
  36. ev.stopPropagation();
  37. const stepValue = (slide.distance / slide.max);
  38. this._nav.swipeBackProgress(stepValue);
  39. }
  40. onSlideEnd(slide, _ev) {
  41. const velocity = slide.velocity;
  42. const currentStepValue = (slide.distance / slide.max);
  43. const isResetDirecction = velocity < 0;
  44. const isMovingFast = Math.abs(slide.velocity) > 0.4;
  45. const isInResetZone = Math.abs(slide.delta) < Math.abs(slide.max) * 0.5;
  46. const shouldComplete = !swipeShouldReset(isResetDirecction, isMovingFast, isInResetZone);
  47. this._nav.swipeBackEnd(shouldComplete, currentStepValue, velocity);
  48. }
  49. }
  50. //# sourceMappingURL=swipe-back.js.map