Skip to content

feat: support lazy-loading HammerJS w/ Angular 6.1 #11960

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2018

Conversation

jelbourn
Copy link
Member

Angular 6.1 adds the HAMMER_LOADER token that can be used to lazy-load
HammerJS. This commit updates Angular Material's gesture config to be
compatible with lazy-loading HammerJS by:

  • Only reading window.Hammer after Angular knows that HammerJS has
    been loaded.
  • Always registering the set of gesture events used in the Angular
    Material components (instead of registering no events when Hammer is
    absent).

Once we are able to depend on HAMMER_LOADER itself (in v7.0), this can
be simplified a bit.

@jelbourn jelbourn added G This is is related to a Google internal issue target: minor This PR is targeted for the next minor release labels Jun 28, 2018
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jun 28, 2018
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// If HammerJS is not loaded here, return the noop HammerInstance. This is necessary to
// ensure that omitting HammerJS completely will not cause any errors while *also* supporting
// the lazy-loading of HammerJS via the HAMMER_LOADER token introduced in Angular 6.1.
// Because we can't depend on HAMMER_LOADER's existance until 7.0, we have to always set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an @deletion-target for 7.0 here so we remember to update it once 7.0 is out?

@crisbeto crisbeto added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jun 28, 2018
@josephperrott josephperrott added the blocked This issue is blocked by some external factor, such as a prerequisite PR label Jun 28, 2018
@josephperrott
Copy link
Member

Blocked by angular/angular#24682

@josephperrott josephperrott removed the action: merge The PR is ready for merge by the caretaker label Jun 28, 2018
@@ -44,12 +44,35 @@ describe('GestureConfig', () => {
expect(firstCallArgs[1].cssProps.touchAction).toBe('auto');
});

it('should should not error when HammerJS is not loaded', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jar jar binks

@jelbourn jelbourn removed the blocked This issue is blocked by some external factor, such as a prerequisite PR label Jun 29, 2018
@jelbourn
Copy link
Member Author

@josephperrott unblocked now that the requisite Angular change is synced

@josephperrott josephperrott added action: merge The PR is ready for merge by the caretaker pr: needs rebase and removed action: merge The PR is ready for merge by the caretaker labels Jul 9, 2018
@jelbourn jelbourn added action: merge The PR is ready for merge by the caretaker and removed pr: needs rebase labels Jul 9, 2018
@angular angular deleted a comment from ngbot bot Jul 9, 2018
Angular 6.1 adds the HAMMER_LOADER token that can be used to lazy-load
HammerJS. This commit updates Angular Material's gesture config to be
compatible with lazy-loading HammerJS by:
* Only reading `window.Hammer` after Angular knows that HammerJS has
been loaded.
* Always registering the set of gesture events used in the Angular
Material components (instead of registering no events when Hammer is
absent).

Once we are able to depend on HAMMER_LOADER itself (in v7.0), this can
be simplified a bit.
@jelbourn jelbourn merged commit eed6110 into angular:master Jul 10, 2018
@alfaproject
Copy link

Jar jar binks lives on!

victoriaaa234 pushed a commit that referenced this pull request Jul 25, 2018
Angular 6.1 adds the HAMMER_LOADER token that can be used to lazy-load
HammerJS. This commit updates Angular Material's gesture config to be
compatible with lazy-loading HammerJS by:
* Only reading `window.Hammer` after Angular knows that HammerJS has
been loaded.
* Always registering the set of gesture events used in the Angular
Material components (instead of registering no events when Hammer is
absent).

Once we are able to depend on HAMMER_LOADER itself (in v7.0), this can
be simplified a bit.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement G This is is related to a Google internal issue target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants