I want to make an animation after dragging. There are no problems with dragging, just assume there is an event document.omouseup to remove the extra js.

The animation is simple: the background turned blue, a second later it came back (no background ).

I just do not understand how to do it. After all, just insert this will not work:

 .color { transition-property: background-color; transition-duration: 1s; } 

UPD: I’ve just figured out how to do it, below code. Is this the most correct option?

 document.omouseup = () => { // Π΄Π΅Π»Π°Π΅ΠΌ Π°Π½ΠΈΠΌΠ°Ρ†ΠΈΡŽ myElem.style.background = 'blue'; myElem.classList.add('color'); myElem.style.background = ''; // ΡƒΠ±ΠΈΡ€Π°Π΅ΠΌ послСдствия Π°Π½ΠΈΠΌΠ°Ρ†ΠΈΠΈ setTimeout(() => { myElem.classList.remove('color'); },1000); } 
  • With drag and drop, in the sense of drag'n'drop? And if the user drags and immediately releases? In your case, the animation will work, although it is not necessary ... In jQuery, you can create your own event, here's an article, google. xandeadx.ru/blog/javascript/355 - Bim Bam

0