Skip to content

Commit 0d7a183

Browse files
committed
refactor: clean up remaining hammer.js usages
Now that none of the components use Hammer.js anymore, we can clean up the remaining usages from the project.
1 parent 8c98013 commit 0d7a183

36 files changed

+55
-421
lines changed

.github/CODEOWNERS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@
148148
/src/dev-app/examples-page/** @andrewseguin
149149
/src/dev-app/expansion/** @jelbourn
150150
/src/dev-app/focus-origin/** @mmalerba
151-
/src/dev-app/gestures/** @jelbourn
152151
/src/dev-app/google-map/** @mbehrlich
153152
/src/dev-app/grid-list/** @jelbourn
154153
/src/dev-app/icon/** @jelbourn

guides/getting-started.md

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,11 @@ ng add @angular/material
1818

1919
The `ng add` command will install Angular Material, the [Component Dev Kit (CDK)](https://material.angular.io/cdk/categories), [Angular Animations](https://angular.io/guide/animations) and ask you the following questions to determine which features to include:
2020

21-
1. Choose a prebuilt theme name, or "custom" for a custom theme:
21+
1. Choose a prebuilt theme name, or "custom" for a custom theme:
2222

2323
You can choose from [prebuilt material design themes](https://material.angular.io/guide/theming#using-a-pre-built-theme) or set up an extensible [custom theme](https://material.angular.io/guide/theming#defining-a-custom-theme).
2424

25-
2. Set up HammerJS for gesture recognition:
26-
27-
[HammerJS](http://hammerjs.github.io/) provides gesture recognition capabilities required by some components (`mat-slide-toggle`, `mat-slider`, `matToolTip`).
28-
29-
Please note, if you choose not to install HammerJS it can be installed later
30-
(see [Appendix](#installing-hammerjs)).
31-
32-
3. Set up browser animations for Angular Material:
25+
2. Set up browser animations for Angular Material:
3326

3427
Importing the [`BrowserAnimationsModule`](https://angular.io/api/platform-browser/animations/BrowserAnimationsModule) into your application enables Angular's [animation system](https://angular.io/guide/animations). Declining this will disable most of Angular Material's animations.
3528

@@ -79,20 +72,3 @@ and point your browser to [http://localhost:4200](http://localhost:4200)
7972
You should see the material slider component on the page.
8073

8174
In addition to the install schematic, Angular Material comes with [several schematics](https://material.angular.io/guide/schematics) (like nav, table, address-form, etc.) that can be used to easily generate pre-built components in your application.
82-
83-
84-
### Appendix
85-
86-
#### Installing HammerJS
87-
88-
[HammerJS](http://hammerjs.github.io/) can be installed using the following npm command:
89-
90-
```bash
91-
npm install --save hammerjs
92-
```
93-
94-
After installing, import it on your app's entry point (e.g. `src/main.ts`).
95-
96-
```ts
97-
import 'hammerjs';
98-
```

guides/schematics.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ The Angular Material `ng add` schematic helps you setup an Angular CLI project t
3030
- Remove margins from `body`
3131
- Set `height: 100%` on `html` and `body`
3232
- Make Roboto the default font of your app
33-
- Install and import `hammerjs` for [gesture support](./getting-started#step-5-gesture-support) in your project
3433

3534

3635
## Component schematics

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
"@types/glob": "^5.0.33",
8484
"@types/gulp": "3.8.32",
8585
"@types/gulp-util": "^3.0.34",
86-
"@types/hammerjs": "^2.0.35",
8786
"@types/inquirer": "^0.0.43",
8887
"@types/jasmine": "^3.4.0",
8988
"@types/marked": "^0.4.2",
@@ -115,7 +114,6 @@
115114
"gulp-rename": "^1.2.2",
116115
"gulp-sass": "^4.0.2",
117116
"gulp-util": "^3.0.8",
118-
"hammerjs": "^2.0.8",
119117
"highlight.js": "^9.11.0",
120118
"husky": "^1.3.1",
121119
"inquirer": "^6.2.0",

src/dev-app/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ ng_module(
3333
"//src/dev-app/examples-page",
3434
"//src/dev-app/expansion",
3535
"//src/dev-app/focus-origin",
36-
"//src/dev-app/gestures",
3736
"//src/dev-app/google-map",
3837
"//src/dev-app/grid-list",
3938
"//src/dev-app/icon",
@@ -132,7 +131,6 @@ dev_server(
132131
"@npm//:node_modules/@material/top-app-bar/dist/mdc.topAppBar.js",
133132
"@npm//:node_modules/@webcomponents/custom-elements/custom-elements.min.js",
134133
"@npm//:node_modules/core-js/client/core.js",
135-
"@npm//:node_modules/hammerjs/hammer.min.js",
136134
"@npm//:node_modules/moment/min/moment-with-locales.min.js",
137135
"@npm//:node_modules/rxjs/bundles/rxjs.umd.min.js",
138136
"@npm//:node_modules/systemjs/dist/system.js",

src/dev-app/dev-app/dev-app-layout.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export class DevAppLayout {
3939
{name: 'Drag and Drop', route: '/drag-drop'},
4040
{name: 'Expansion Panel', route: '/expansion'},
4141
{name: 'Focus Origin', route: '/focus-origin'},
42-
{name: 'Gestures', route: '/gestures'},
4342
{name: 'Google Map', route: '/google-map'},
4443
{name: 'Grid List', route: '/grid-list'},
4544
{name: 'Icon', route: '/icon'},

src/dev-app/dev-app/dev-app-module.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
import {CommonModule} from '@angular/common';
1010
import {NgModule} from '@angular/core';
1111
import {MatButtonModule} from '@angular/material/button';
12-
import {GestureConfig} from '@angular/material/core';
1312
import {MatIconModule} from '@angular/material/icon';
1413
import {MatListModule} from '@angular/material/list';
1514
import {MatSidenavModule} from '@angular/material/sidenav';
1615
import {MatToolbarModule} from '@angular/material/toolbar';
17-
import {HAMMER_GESTURE_CONFIG} from '@angular/platform-browser';
1816
import {RouterModule} from '@angular/router';
1917
import {DevApp404} from './dev-app-404';
2018
import {DevAppHome} from './dev-app-home';
@@ -32,10 +30,6 @@ import {DevAppLayout} from './dev-app-layout';
3230
],
3331
declarations: [DevAppLayout, DevAppHome, DevApp404],
3432
exports: [DevAppLayout],
35-
36-
// We need to pass this in here, because the gesture config currently doesn't for lazy-loaded
37-
// modules. See https://github.com/angular/components/issues/4595#issuecomment-416641018.
38-
providers: [{provide: HAMMER_GESTURE_CONFIG, useClass: GestureConfig}]
3933
})
4034
export class DevAppModule {
4135
}

src/dev-app/dev-app/routes.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export const DEV_APP_ROUTES: Routes = [
3939
path: 'focus-origin',
4040
loadChildren: 'focus-origin/focus-origin-demo-module#FocusOriginDemoModule'
4141
},
42-
{path: 'gestures', loadChildren: 'gestures/gestures-demo-module#GesturesDemoModule'},
4342
{path: 'google-map', loadChildren: 'google-map/google-map-demo-module#GoogleMapDemoModule'},
4443
{path: 'grid-list', loadChildren: 'grid-list/grid-list-demo-module#GridListDemoModule'},
4544
{path: 'icon', loadChildren: 'icon/icon-demo-module#IconDemoModule'},

src/dev-app/gestures/BUILD.bazel

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/dev-app/gestures/gestures-demo-module.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/dev-app/gestures/gestures-demo.html

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/dev-app/gestures/gestures-demo.scss

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/dev-app/gestures/gestures-demo.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/dev-app/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
</body>
2727
<script src="core-js/client/core.js"></script>
2828
<script src="zone.js/dist/zone.js"></script>
29-
<script src="hammerjs/hammer.min.js"></script>
3029

3130
<script src="systemjs/dist/system.js"></script>
3231
<script src="system-config.js"></script>

src/e2e-app/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ ts_devserver(
112112
static_files = [
113113
"@npm//zone.js",
114114
"@npm//core-js",
115-
"@npm//hammerjs",
116115
"@npm//material-components-web",
117116
"@npm//moment",
118117
"@npm//@webcomponents/custom-elements",

src/e2e-app/e2e-app/e2e-app-module.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88

99
import {CommonModule} from '@angular/common';
1010
import {NgModule} from '@angular/core';
11-
import {GestureConfig} from '@angular/material/core';
1211
import {MatListModule} from '@angular/material/list';
13-
import {HAMMER_GESTURE_CONFIG} from '@angular/platform-browser';
1412
import {RouterModule} from '@angular/router';
1513
import {E2eAppLayout, Home} from './e2e-app-layout';
1614

@@ -22,10 +20,6 @@ import {E2eAppLayout, Home} from './e2e-app-layout';
2220
],
2321
declarations: [E2eAppLayout, Home],
2422
exports: [E2eAppLayout],
25-
26-
// We need to pass this in here, because the gesture config currently doesn't for lazy-loaded
27-
// modules. See https://github.com/angular/components/issues/4595#issuecomment-416641018.
28-
providers: [{provide: HAMMER_GESTURE_CONFIG, useClass: GestureConfig}]
2923
})
3024
export class E2eAppModule {
3125
}

src/e2e-app/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<!-- Static scripts which are not imported through AMD nor part of the ConcatJS bundle. -->
3030
<script src="core-js/client/core.min.js"></script>
3131
<script src="zone.js/dist/zone.min.js"></script>
32-
<script src="hammerjs/hammer.min.js"></script>
3332

3433
<!-- ConcatJS bundle from the Bazel TypeScript devserver. -->
3534
<script src="bundle.js"></script>

src/material-experimental/mdc-slide-toggle/README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,6 @@ component by following these steps:
6464
@include mat-slide-toggle-typography-mdc();
6565
```
6666

67-
## API differences
68-
The experimental slide toggle API closely matches the
69-
[API of the standard slide toggle](https://material.angular.io/components/slide-toggle/api).
70-
`@angular/material-experimental/mdc-slide-toggle` exports symbols with the same name and public
71-
interface as all of the symbols found under `@angular/material/slide-toggle`, except for the
72-
following differences:
73-
74-
* The MDC-based `mat-slide-toggle` drops the dependency on Hammer.js and as a result doesn't support
75-
dragging gestures.
76-
* As a result of dragging gestures not being supported, the `dragChange` event won't emit.
77-
7867
## Replacing the standard slide toggle in an existing app
7968
Because the experimental API mirrors the API for the standard slide toggle, it can easily be swapped
8069
in by just changing the import paths. There is currently no schematic for this, but you can run the

src/material/core/common-behaviors/common-module.ts

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import {NgModule, InjectionToken, Optional, Inject, isDevMode, Version} from '@angular/core';
10-
import {HammerLoader, HAMMER_LOADER} from '@angular/platform-browser';
1110
import {BidiModule} from '@angular/cdk/bidi';
1211
import {VERSION as CDK_VERSION} from '@angular/cdk';
1312

@@ -39,6 +38,11 @@ export interface GranularSanityChecks {
3938
doctype: boolean;
4039
theme: boolean;
4140
version: boolean;
41+
42+
/**
43+
* @deprecated No longer being used.
44+
* @breaking-change 10.0.0
45+
*/
4246
hammer: boolean;
4347
}
4448

@@ -56,9 +60,6 @@ export class MatCommonModule {
5660
/** Whether we've done the global sanity checks (e.g. a theme is loaded, there is a doctype). */
5761
private _hasDoneGlobalChecks = false;
5862

59-
/** Whether we've already checked for HammerJs availability. */
60-
private _hasCheckedHammer = false;
61-
6263
/** Reference to the global `document` object. */
6364
private _document = typeof document === 'object' && document ? document : null;
6465

@@ -68,10 +69,7 @@ export class MatCommonModule {
6869
/** Configured sanity checks. */
6970
private _sanityChecks: SanityChecks;
7071

71-
constructor(
72-
@Optional() @Inject(MATERIAL_SANITY_CHECKS) sanityChecks: any,
73-
@Optional() @Inject(HAMMER_LOADER) private _hammerLoader?: HammerLoader) {
74-
72+
constructor(@Optional() @Inject(MATERIAL_SANITY_CHECKS) sanityChecks: any) {
7573
// Note that `_sanityChecks` is typed to `any`, because AoT
7674
// throws an error if we use the `SanityChecks` type directly.
7775
this._sanityChecks = sanityChecks;
@@ -152,20 +150,4 @@ export class MatCommonModule {
152150
);
153151
}
154152
}
155-
156-
/** Checks whether HammerJS is available. */
157-
_checkHammerIsAvailable(): void {
158-
if (this._hasCheckedHammer || !this._window) {
159-
return;
160-
}
161-
162-
const isEnabled = this._checksAreEnabled() &&
163-
(this._sanityChecks === true || (this._sanityChecks as GranularSanityChecks).hammer);
164-
165-
if (isEnabled && !(this._window as any)['Hammer'] && !this._hammerLoader) {
166-
console.warn(
167-
'Could not find HammerJS. Certain Angular Material components may not work correctly.');
168-
}
169-
this._hasCheckedHammer = true;
170-
}
171153
}

0 commit comments

Comments
 (0)