Solved

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

Posted on 2014-02-20
3
692 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 55

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What does GoogleTagMgr javascripts below do 5 29
parse url to form? 7 25
jQuery on Submit 4 39
Copying table data to one another 15 29
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
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…

840 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