Created
July 19, 2017 12:25
-
-
Save dpmango/b849907643fbe356d20c17c74565c33e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hero parallax on mousemove | |
var movementStrength = 50; | |
var height = movementStrength / _window.height(); | |
var width = movementStrength / _window.width(); | |
$(".hero").mousemove(function(e){ | |
var pageX = e.pageX - (_window.width() / 2); | |
var pageY = e.pageY - (_window.height() / 2); | |
var newvalueX = width * pageX * -1 - 25; | |
var newvalueY = height * pageY * -1 - 50; | |
$('.hero-bg').css("background-position", newvalueX+"px "+newvalueY+"px"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment