Created
July 29, 2014 23:14
-
-
Save jasonyarrington/3f340c7d2cd5b389c83e 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
body { | |
background-color: blue; | |
} | |
.top-spacer { | |
height: 100px; | |
} | |
.wrapper { | |
border: 1px solid orange; | |
overflow: hidden; | |
} | |
.content { | |
border: 1px solid blue; | |
background-color: red; | |
} | |
.spacer { | |
height: 5000px; | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="translate3d window shade" /> | |
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<div class="top-spacer">spacer</div> | |
<div class="wrapper"> | |
<div class="content"> | |
This is me | |
</div> | |
</div> | |
<div class="spacer">spacer</div> | |
</body> | |
</html> |
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
$(window).on('scroll', function() { | |
var s = $(window).scrollTop(); | |
console.log(s); | |
$('.wrapper').css('transform', 'translate3d(0,' + s + 'px, 0)'); | |
$('.content').css('transform', 'translate3d(0,' + -s + 'px, 0)'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment