diff --git a/src/gestures/drag-gesture.ts b/src/gestures/drag-gesture.ts index f1ea44d07c..3aa6d4369a 100644 --- a/src/gestures/drag-gesture.ts +++ b/src/gestures/drag-gesture.ts @@ -1,9 +1,8 @@ - -import { defaults } from '../util'; +import { defaults } from '../util/util'; import { GestureDelegate } from '../gestures/gesture-controller'; -import { PointerEvents, UIEventManager } from '../util/ui-event-manager'; import { PanRecognizer } from './recognizers'; -import { pointerCoord, Coordinates } from '../util/dom'; +import { PointerEvents, UIEventManager } from '../util/ui-event-manager'; +import { pointerCoord } from '../util/dom'; /** * @private @@ -19,7 +18,6 @@ export interface PanGestureConfig { * @private */ export class PanGesture { - private dragging: boolean; private events: UIEventManager = new UIEventManager(false); private pointerEvents: PointerEvents; private detector: PanRecognizer; diff --git a/src/gestures/ionic-gesture-config.ts b/src/gestures/gesture-config.ts similarity index 62% rename from src/gestures/ionic-gesture-config.ts rename to src/gestures/gesture-config.ts index ca3877e195..6e0ad9fa6b 100644 --- a/src/gestures/ionic-gesture-config.ts +++ b/src/gestures/gesture-config.ts @@ -1,19 +1,16 @@ import { Injectable } from '@angular/core'; import { HammerGestureConfig } from '@angular/platform-browser'; -/* this class override the default angular gesture config. - * The motivation for this is enabling pinch, rotate or - * any other multi-touch gestures block scrolling. - */ /** * @private + * This class overrides the default Angular gesture config. */ @Injectable() export class IonicGestureConfig extends HammerGestureConfig { - + buildHammer(element: HTMLElement) { - var mc = new ( window).Hammer(element); + const mc = new ( window).Hammer(element); for (let eventName in this.overrides) { mc.get(eventName).set(this.overrides[eventName]); @@ -22,4 +19,4 @@ export class IonicGestureConfig extends HammerGestureConfig { return mc; } -} \ No newline at end of file +} diff --git a/src/gestures/gesture-controller.ts b/src/gestures/gesture-controller.ts index d40d4e4473..13287b6b65 100644 --- a/src/gestures/gesture-controller.ts +++ b/src/gestures/gesture-controller.ts @@ -1,4 +1,3 @@ - import { forwardRef, Inject, Injectable } from '@angular/core'; import { App } from '../components/app/app'; diff --git a/src/gestures/gesture.ts b/src/gestures/gesture.ts index 9d40d37d35..375710cd0c 100644 --- a/src/gestures/gesture.ts +++ b/src/gestures/gesture.ts @@ -1,4 +1,4 @@ -import { defaults, assign } from '../util'; +import { defaults, assign } from '../util/util'; import { Hammer, DIRECTION_HORIZONTAL, DIRECTION_VERTICAL } from './hammer'; /** diff --git a/src/gestures/recognizers.ts b/src/gestures/recognizers.ts index ad63faaebe..b2495c1e78 100644 --- a/src/gestures/recognizers.ts +++ b/src/gestures/recognizers.ts @@ -1,7 +1,8 @@ -import { pointerCoord, Coordinates } from '../util/dom'; +import { PointerCoordinates } from '../util/dom'; + export class PanRecognizer { - private startCoord: Coordinates; + private startCoord: PointerCoordinates; private dirty: boolean = false; private threshold: number; private maxCosine: number; @@ -14,14 +15,14 @@ export class PanRecognizer { this.threshold = threshold * threshold; } - start(coord: Coordinates) { + start(coord: PointerCoordinates) { this.startCoord = coord; this._angle = 0; this._isPan = 0; this.dirty = true; } - detect(coord: Coordinates): boolean { + detect(coord: PointerCoordinates): boolean { if (!this.dirty) { return false; } diff --git a/src/gestures/simulator.ts b/src/gestures/simulator.ts index dc304bcf20..cdca6c5977 100644 --- a/src/gestures/simulator.ts +++ b/src/gestures/simulator.ts @@ -1,7 +1,7 @@ -import { pointerCoord, Coordinates } from '../util/dom'; +import { PointerCoordinates } from '../util/dom'; interface Point { - coord: Coordinates; + coord: PointerCoordinates; duration: number; } @@ -121,7 +121,7 @@ export class Simulate { } - private newPoint(coord: Coordinates, duration: number) { + private newPoint(coord: PointerCoordinates, duration: number) { this.points.push({ coord: coord, duration: duration, @@ -149,15 +149,15 @@ function randomAngle(maxAngle: number): number { return (Math.random() * maxAngle * 2) - maxAngle; } -function distance(a: Coordinates, b: Coordinates): number { +function distance(a: PointerCoordinates, b: PointerCoordinates): number { let deltaX = a.x - b.x; let deltaY = a.y - a.y; return Math.hypot(deltaX, deltaY); } -function parseCoordinates(coord: Coordinates | number, y?: number): Coordinates { +function parseCoordinates(coord: PointerCoordinates | number, y?: number): PointerCoordinates { if (typeof coord === 'number') { return { x: coord, y: y }; } return coord; -} \ No newline at end of file +} diff --git a/src/gestures/slide-gesture.ts b/src/gestures/slide-gesture.ts index 2d57162227..29bd411a90 100644 --- a/src/gestures/slide-gesture.ts +++ b/src/gestures/slide-gesture.ts @@ -1,5 +1,5 @@ import { PanGesture } from './drag-gesture'; -import { clamp } from '../util'; +import { clamp } from '../util/util'; import { pointerCoord } from '../util/dom'; /** diff --git a/src/gestures/test/gesture-controller.spec.ts b/src/gestures/test/gesture-controller.spec.ts index b930d1a95b..d19962b150 100644 --- a/src/gestures/test/gesture-controller.spec.ts +++ b/src/gestures/test/gesture-controller.spec.ts @@ -1,7 +1,6 @@ -import { GestureController, DisableScroll } from '../../../src'; - -export function run() { +import { GestureController, DisableScroll } from '../gesture-controller'; +describe('gesture controller', () => { it('should create an instance of GestureController', () => { let c = new GestureController(null); expect(c.isCaptured()).toEqual(false); @@ -310,5 +309,4 @@ export function run() { g.destroy(); expect(c.isScrollDisabled()).toEqual(false); }); - -} +}); diff --git a/src/gestures/test/ionic-gesture-config.spec.ts b/src/gestures/test/ionic-gesture-config.spec.ts deleted file mode 100644 index 5c9529b537..0000000000 --- a/src/gestures/test/ionic-gesture-config.spec.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { IonicGestureConfig } from '../../../src/gestures/ionic-gesture-config'; - -export function run() { - - describe('IonicGestureConfig', () => { - it('should create a new instance of hammer', () => { - // arrange - let instance = new IonicGestureConfig(); - let expectedParam = { name: "expectedParam"}; - let expectedHammerInstance = { name: "hammer"}; - - let actualParam : any = null; - let callCount = 0; - - ( window).Hammer = (param: any) => { - callCount++; - actualParam = param; - return expectedHammerInstance; - }; - - // act - let returnValue = instance.buildHammer( expectedParam); - - // assert - expect(returnValue.name).toEqual(expectedHammerInstance.name); - expect(callCount).toEqual(1); - expect(actualParam.name).toEqual(expectedParam.name); - }); - }) - -} \ No newline at end of file diff --git a/src/gestures/test/recognizers.spec.ts b/src/gestures/test/recognizers.spec.ts index cd3a47bcd6..dcd089f6e0 100644 --- a/src/gestures/test/recognizers.spec.ts +++ b/src/gestures/test/recognizers.spec.ts @@ -1,9 +1,8 @@ -import { PanRecognizer } from '../../../src/gestures/recognizers'; -import { Simulate } from '../../../src/gestures/simulator'; - -export function run() { +import { PanRecognizer } from '../recognizers'; +import { Simulate } from '../simulator'; +describe('recognizers', () => { it('should not fire if it did not start', () => { let p = new PanRecognizer('x', 2, 2); expect(p.pan()).toEqual(0); @@ -203,4 +202,4 @@ export function run() { expect(p.pan()).toEqual(0); }); -} +});