Solved

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

Posted on 2014-02-20
3
684 Views
Last Modified: 2014-02-27
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
Comment
Question by:coolispaul
3 Comments
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 39874578
Do you have a link we can look at?
0
 
LVL 9

Accepted Solution

by:
Sar1973 earned 500 total points
ID: 39876326
Shouldn't you invert the formula ...(strength2 / $(window).width() * pageX * -1) with ...(1-strength2 / $(window).width() * pageX)?
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now