?
Solved

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

Posted on 2014-02-20
3
Medium Priority
?
707 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 58

Expert Comment

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

Accepted Solution

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

Featured Post

Tutorial: Introduction to Managing a Linux Server

In this tutorial on systemd, we will explore:
-OS/Distro Adoption
-chkconfig and Other Legacy Commands
-Summary and Key Commands

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
This article discusses how to create an extensible mechanism for linked drop downs.
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…
Suggested Courses

765 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