-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(gestures): fixes scroll issue with hammer config
fixes scroll issue with hammer config where pinch/rotate gestures are preventing the screen from scrolling closes #6897
- Loading branch information
1 parent
e244d09
commit f066837
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
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 | ||
*/ | ||
@Injectable() | ||
export class IonicGestureConfig extends HammerGestureConfig { | ||
|
||
buildHammer(element: HTMLElement) { | ||
var mc = new (<any> window).Hammer(element); | ||
|
||
for (let eventName in this.overrides) { | ||
mc.get(eventName).set(this.overrides[eventName]); | ||
} | ||
|
||
return mc; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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; | ||
|
||
(<any> window).Hammer = (param: any) => { | ||
callCount++; | ||
actualParam = param; | ||
return expectedHammerInstance; | ||
}; | ||
|
||
// act | ||
let returnValue = instance.buildHammer( <HTMLElement> <any> expectedParam); | ||
|
||
// assert | ||
expect(returnValue.name).toEqual(expectedHammerInstance.name); | ||
expect(callCount).toEqual(1); | ||
expect(actualParam.name).toEqual(expectedParam.name); | ||
}); | ||
}) | ||
|
||
} |