Skip to content

Instantly share code, notes, and snippets.

@stephen-james
Created August 30, 2013 13:07
Show Gist options
  • Save stephen-james/6389654 to your computer and use it in GitHub Desktop.
Save stephen-james/6389654 to your computer and use it in GitHub Desktop.
playing with mouse based paralax need to refine this
$(document).mousemove(function (event) {
console.log(event);
var offsetPercentageX = Math.floor(event.clientX / window.innerWidth * 20) + "%";
var offsetPercentageY = Math.floor(event.clientY / window.innerHeight * 20) + "%";
$("section.content").css("background-position", offsetPercentageX + " " + offsetPercentageY);
});
section.content
{
transition : background-position ease-in-out 0.1s;
background: url(/content/img/barrel_background_semitrans.png) no-repeat 10% 10%;
background-size: 120%;
padding : 20px;
width : 100%;
display : block;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment