• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 718
  • Last Modified:

Move background image based on mouse position from right side of screen

Hi

Im moving a background image based on x mouse position with :

$("html").mousemove(function(e){
  var strength1 = 100;
  var pageX = e.pageX - ($(window).width() / 2);
  $('#foreground1').css("background-position", (strength2 / $(window).width() * pageX * -1));
}

Open in new window

this works fine with images on left. How can i adjust this for an image sat on the right of the screen?

Thanks
0
coolispaul
Asked:
coolispaul
1 Solution
 
Julian HansenCommented:
Do you have a link we can look at?
0
 
Sar1973Commented:
Shouldn't you invert the formula ...(strength2 / $(window).width() * pageX * -1) with ...(1-strength2 / $(window).width() * pageX)?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now