Skip to content

Instantly share code, notes, and snippets.

@joshblack
Created March 27, 2014 19:43
Show Gist options
  • Save joshblack/9816447 to your computer and use it in GitHub Desktop.
Save joshblack/9816447 to your computer and use it in GitHub Desktop.
A Pen by Josh Black.
<!-- <3 Angelina Fabbro -->
<img src="http://farm9.staticflickr.com/8189/8148307537_7756003b1c_o.jpg">
var $img = $('img');
$img.on('mousemove', function(event) {
var styles = {
'-webkit-transform': 'translate3d(' + (event.pageX / -128) + 'px,' + (event.pageY / -128) + 'px,0)',
'-moz-transform': 'translate3d(' + (event.pageX / -128) + 'px,' + (event.pageY / -128) + 'px,0)',
'-o-transform': 'translate3d(' + (event.pageX / -128) + 'px,' + (event.pageY / -128) + 'px,0)',
'transform': 'translate3d(' + (event.pageX / -128) + 'px,' + (event.pageY / -128) + 'px,0)'
};
$img.css(styles);
});

Squarespace Background Effect

Trying to mimic Squarespace's current background effect where it follows the motion of your mouse

A Pen by Josh Black on CodePen.

License.

body {
margin: 0;
}
img {
min-height: 100%;
min-width: 1024px;
width: 105%;
height: auto;
position: fixed;
top: -50px;
left: -50px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment