Skip to content

Commit 8ac15b1

Browse files
committed
proposed edits
1 parent 7a32187 commit 8ac15b1

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

guides/v9-hammerjs-migration.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# V9 HammerJS migration
22

3-
In Angular Material version 9, the dependency on HammerJS has been dropped. Components which
3+
Angular Material, as of version 9, no longer requires HammerJS for any component. Components which
44
previously depended on HammerJS, no longer provide a [`HAMMER_GESTURE_CONFIG`][1] that will
55
enable use of HammerJS events in templates.
66

@@ -10,33 +10,37 @@ deprecated and will be removed in version 10.
1010
### Why is a migration needed?
1111

1212
Since HammerJS previously was a requirement for a few Angular Material components, projects might
13-
have installed `HammerJS` for these. Since HammerJS is no longer needed when updating to v9, the
14-
dependency on HammerJS can be unnecessary and should be removed.
13+
have installed `HammerJS` exclusively for Angular Material. Since HammerJS is no longer needed when
14+
updating to v9, the dependency on HammerJS can be removed if it's not used directly in the
15+
application.
1516

1617
In some cases, projects use HammerJS events in templates while relying on Angular Material
1718
modules to set up the HammerJS event plugin. Since this is no longer the case in version 9,
1819
such projects need to manually configure the HammerJS event plugin in order to continue using
1920
these HammerJS events.
2021

21-
### How does the migration work?
22+
### What does the migration do?
2223

23-
The migration automatically removes HammerJS from the project if HammerJS is not used in the
24-
project anywhere. If HammerJS events provided by the deprecated `GestureConfig` are used in
25-
templates, the migration will set up a new config that supports the used events, and the
26-
`HammerModule` which enables event bindings to HammerJS in templates.
24+
The migration automatically removes HammerJS from the project if HammerJS is not used.
2725

28-
In case a custom [`HAMMER_GESTURE_CONFIG`][1] is provided and there are references to the
26+
Additionally, Angular Material's `GestureConfig` (now deprecated) defined custom HammerJS gestures.
27+
If the application directly uses any of these gestures, the migration will introduce a new
28+
application-specific configuration for these custom gestures, removing the dependency on Angular
29+
Material's `GestureConfig`.
30+
31+
Finally, if the application uses HammerJS directly, the migration will add an import for Angular's
32+
new `HammerModule`, which enabled HammerJS event bindings. These bindings were previously enabled
33+
by default in Angular versions 8 and below.
34+
35+
If your application provides a custom [`HAMMER_GESTURE_CONFIG`][1] and also references the
2936
deprecated Angular Material `GestureConfig`, the migration will print a warning about
3037
ambiguous usage. The migration cannot migrate the project automatically and manual changes
3138
are required. Read more [in the dedicated section](#The-migration-reported-ambiguous-usage-What-should-I-do).
3239

33-
### How can I remove HammerJS from the project?
34-
35-
As explained in the section above, if you do not use HammerJS in your project, the migration
36-
removes HammerJS from your project. The migration performs the following steps:
40+
### How does the schematic remove HammerJS?
3741

38-
_Disclaimer:_ HammerJS can be set up in lots of different ways. The migration only handles
39-
the most common cases which were also recommended by Angular Material in the past.
42+
HammerJS can be set up in many ways. The migration handles the most common cases, covering
43+
approaches recommended by Angular Material in the past. The migration performs the following steps:
4044

4145
*1\.* Remove `hammerjs` from the project `package.json`.
4246
```json
@@ -55,14 +59,14 @@ the most common cases which were also recommended by Angular Material in the pas
5559
import 'hammerjs';
5660
```
5761

58-
The migration does not automatically remove HammerJS from tests. Please manually clean up
59-
the test setup, and resolve any test issues. Read more in a [dedicated section for test migration](#How-to-migrate-my-tests)
62+
The migration cannot automatically remove HammerJS from tests. Please manually clean up
63+
the test setup and resolve any test issues. Read more in a
64+
[dedicated section for test migration](#How-to-migrate-my-tests)
6065

6166
### How do I migrate references to the deprecated `GestureConfig`?
6267

63-
The `GestureConfig` can be consumed in a lot of possible ways. This section only covers the
64-
most common cases which are also handled by the migration. The most common case is that the
65-
deprecated `GestureConfig` is manually provided in an `NgModule` of the project.
68+
The `GestureConfig` can be consumed in multiple ways. The migration covers the most common cases.
69+
The most common case is that an `NgModule` in your application directly provides `GestureConfig`:
6670

6771
```typescript
6872
import {GestureConfig} from '@angular/material/core';
@@ -76,7 +80,7 @@ import {GestureConfig} from '@angular/material/core';
7680
export class AppModule {}
7781
```
7882

79-
If such pattern can be found in the project, it usually means that a component relies on the
83+
If this pattern is found in the project, it usually means that a component relies on the
8084
deprecated `GestureConfig` in order to use HammerJS events in the template. If this is the case,
8185
the migration automatically creates a new gesture config which supports the used HammerJS
8286
events. All references to the deprecated gesture config will be rewritten to the newly created one.
@@ -91,7 +95,7 @@ automatically, but the migration will report such patterns and ask for manual cl
9195
<a name="test-migration"></a>
9296
### How to migrate my tests?
9397

94-
Components of your project might use Angular Material components which previously depended
98+
Components in your project might use Angular Material components which previously depended
9599
on HammerJS. There might be unit tests for these components which also test gesture functionality
96100
of the Angular Material components. For such unit tests, find all failing gesture tests. These
97101
might need to be reworked to dispatch proper events to simulate gestures, or need to be deleted.

0 commit comments

Comments
 (0)