V
V
VVS102020-05-15 15:42:35
css
VVS10, 2020-05-15 15:42:35

How to implement hover effect for touch (mobile) devices?

Hello!

The essence of the problem is in the "sticking" of buttons with hover effects on mobile, how can you implement this so that the color changes only when you click on the button or div and immediately returns to its original position.

Link to buttons: https://jsfiddle.net/vvs10/pL14gfwa/1/

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VVS10, 2020-05-16
@VVS10

I solved the problem with touch screens with the following code:

document.querySelector('.pleer-controls__right').addEventListener("touchstart", myTouch);
document.querySelector('.pleer-controls__right').addEventListener("touchend", myTouchEnd);

function myTouch(){
  $(this).toggleClass('clicked');
}

function myTouchEnd(){
  $(this).removeClass('clicked');
}

L
Lord_Dantes, 2020-05-15
@Lord_Dantes

https://habr.com/ru/post/213801/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question