How to add a smoothness to the image when you rotate the mouse?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
12 views
Salam guys, make a fixed picture when vertically moving the mouse, i.e. there is a picture in the background is a picture of the front, the implementation works like this:

$(document).ready(function() { var pixelToMove = 20; $(".hero-banner__residence").mousemove(function(e) { var width = $(this).innerWidth(); var height = $(this).innerHeight(); var newValueX = (e.pageX / width) * pixelToMove; var newValueY = (e.pageY / height) * pixelToMove; $(this).css('background-position', newValueX + '%'); }); });


but all is tough, I want to add smoothness to the movement was soft, tell me what should I add to my code ?
by | 12 views

1 Answer

0 like 0 dislike
$(document).ready(function() { var pixelToMove = 20; $(".hero-banner__residence").mousemove(function(e) { var width = $(this).innerWidth(); var height = $(this).innerHeight(); var newValueX = (e.pageX / width) * pixelToMove; var newValueY = (e.pageY / height) * pixelToMove; $(this).animate({ 'background-position': newValueX + '%', }, 5000, 'linear'); }); });

So? Can play with the speed value changes(5000)
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked Apr 12, 2019 by AntonVirovets
0 like 0 dislike
1 answer
asked Jun 14, 2019 by UnluckySerivelha
0 like 0 dislike
3 answers
110,608 questions
257,187 answers
0 comments
40,796 users