+ 10

[JavaScript/JQuery] Problem With TransitionEnd Event

Transitionend event is an event that triggers when CSS transition is finished. I definitely need transitionend event for my project. So I made a simple demo. https://code.sololearn.com/Wpy7i4s4a91v/?ref=app But I got a new problem... It fires 2times on same transition end. (maybe the reason is in css - transition: all 0.5s) How can I make transitionend trigger only once without altering css or using mutation observer. I need something like stopImmediatePropagation() method when same event trigger.

6th Jun 2017, 11:48 PM
김정제(Legacy)
김정제(Legacy) - avatar
5 Réponses
0
It triggers twice due to transition all. Transition left and transition top both fire the event. Try to condition it by e.propertyName. I think you might need to use Javascript, not jQuery. Coz jQuery event does not carry propertyName property.
7th Jun 2017, 3:20 AM
Calviղ
Calviղ - avatar
+ 8
@Calvin Oh Thats why it throw undefined when I used e.propertyName... Thanks I'll try it with js.
7th Jun 2017, 3:27 AM
김정제(Legacy)
김정제(Legacy) - avatar
+ 8
@Calvin Thank you for your effort. :D But, I want to trigger this event when just left position is moved. It may not work If I do like box.css({ left: "+=20px" })
7th Jun 2017, 4:03 AM
김정제(Legacy)
김정제(Legacy) - avatar
7th Jun 2017, 3:39 AM
Calviղ
Calviղ - avatar
0
This is tricky. You might need to keep track of the triggering time frame.
7th Jun 2017, 4:06 AM
Calviղ
Calviղ - avatar