-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Trigger event on dom object when activated #164
Conversation
emitEvent: (elem, event) -> | ||
if elem.dispatchEvent? # W3C DOM | ||
elem.dispatchEvent(event) | ||
else if elem[event]? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use else if event of elem
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't that just be confusing? Not sure if it's worth debating and if it helps consistency then it's fine by me. I'll make some changes then.
I like this, @mdeboer. Please have a look at my comments when you have some time, and I'll merge this. |
resetAnimation: (event) -> | ||
if event.type.toLowerCase().indexOf('animationend') >= 0 | ||
target = event.target || event.srcElement | ||
target.className = target.className.replace(config.animateClass, '').trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will leave double spaces if the animateClass
is not the first or last class. But then again, who cares. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the behaviour what I have seen but I have only tested briefly.
Thanks @mdeboer, I'll merge this tonight. |
Cheers mate, appreciate it! I'll fix the things you pointed out when I have the time. |
Fixed the things you pointed out @attilaolah 👍 When will it be merged? |
Sorry I completely forgot about this. LGTM, merging. |
Trigger event on dom object when activated
How to implement animationend? |
config.animateClass undifined |
Instead of only having a global callback that has the activated element as argument, it's nice to have an event triggered on the element itself. Should avoid cluttering the global callback function with if's.
Also added a jasmine test to check it's behaviour.