Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(gesture): Implement proper event dispatching when using JQuery #1367

Closed
wants to merge 1 commit into from
Closed

fix(gesture): Implement proper event dispatching when using JQuery #1367

wants to merge 1 commit into from

Conversation

Toilal
Copy link
Contributor

@Toilal Toilal commented Feb 2, 2015

Close #1359

For on and off, jqLite use native events, but JQuery doesn't . So to trigger events properly when JQuery is loaded, the JQuery trigger method must be used instead of native dispatchEvent method.

@@ -361,10 +361,11 @@ angular.module('material.core')
bubbles: true,
cancelable: true
};

/*
* NOTE: dispatchEvent is very performance sensitive.
Copy link
Member

Choose a reason for hiding this comment

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

The name here probably needs to be changed as well
OR
I'm not sure that the name needs to specifically contain jqLite or if it would be enough to just add that to the comment here.

@Splaktar
Copy link
Member

Splaktar commented Feb 2, 2015

LGTM! Thanks!

@@ -302,7 +302,7 @@ angular.module('material.core')
onCancel: angular.noop,
options: {},

dispatchEvent: dispatchEvent,
dispatchEvent: typeof jQuery !== 'undefined' && angular.element === jQuery ? jQueryDispatchEvent : nativeDispatchEvent,
Copy link
Member

Choose a reason for hiding this comment

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

Beware that this will probably break (in certain cases) once angular/angular.js#10761 lands (and I believe it's pretty close to landing).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we would need to check if jQuery object is really jQuery, but it should work even after merge from what I can read.

Copy link
Member

Choose a reason for hiding this comment

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

It has been merged, btw. The problem is that typeof jQuery !== 'undefined' && angular.element === jQuery might evaluate to false (thus using nativeDispatchEvent although jQuery is used (leading to the wrong behaviour again)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, jQuery may be defined as another name in global namespace, and then properly register using the new ngJq directive.

Maybe we should only check if angular.element has trigger function ? jqLite doesn't have this function.

https://github.com/angular/angular.js/blob/master/src/Angular.js#L1532-L1536

Copy link
Contributor

Choose a reason for hiding this comment

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

@rschmukler - Can you follow-up on this issue?

@ajoslin ajoslin closed this in 88813b7 Feb 4, 2015
@ajoslin
Copy link
Contributor

ajoslin commented Feb 4, 2015

Merged, with a small addition to be sure jQuery users get metaKey/ctrlKey/ etc: 88813b7#diff-a82fbe888db156ef2e09e7fcfb85f189R370

Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mdGestures breaks Ripple effect when using JQuery
5 participants