Created
August 17, 2016 14:44
-
-
Save Ivanopalas/1d8ed040b59a3398081ec63a3678d7eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function parallax() { | |
var layer = $('.parallax').find('.parallax__layer'); | |
$(window).on('mousemove', function (e) { | |
var mouseX = e.pageX; | |
var mouseY = e.pageY; | |
var w = (window.innerWidth / 2) - mouseX; | |
var h = (window.innerHeight / 2) - mouseY; | |
layer.map(function (key, value) { | |
var bottomPosition = (window.innerHeight / 2) * (key / 100); | |
var widthPosition = w * (key / 100); | |
var heightPosition = h * (key / 100); | |
$(value).css({ | |
'bottom' : '-' + bottomPosition + 'px', | |
'transform' : 'translate3d(' + widthPosition + 'px, ' + heightPosition + 'px, 0)' | |
}); | |
}); | |
}); | |
} | |
var layer = $('.parallax').find('.parallax__layer'); | |
var width = window.innerWidth + 100; | |
layer.map(function (key, value) { | |
$(value).css({ | |
'width' : width + 'px', | |
'margin-left': -(width / 2) + 'px' | |
}) | |
}); | |
parallax(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment