Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function scrollSidebar() {
- var $sidebar = $(".sideBar"),
- $window = $(window),
- $mainImage = $(".mainImage"),
- offset = $sidebar.offset(),
- threshold = $mainImage.height() - $sidebar.height(),
- topPadding = 15;
- if( $mainImage.height() >= 400 ) {
- $window.scroll(function() {
- if ($window.scrollTop() > threshold) {
- $sidebar.stop().animate({
- marginTop: threshold + 60
- });
- } else if ($window.scrollTop() > offset.top) {
- $sidebar.stop().animate({
- marginTop: $window.scrollTop() - offset.top + topPadding
- });
- } else {
- $sidebar.stop().animate({
- marginTop: '40px'
- });
- }
- });
- $('a.zoomedImage').click(function() {
- setTimeout(scrollSidebar, 1000);
- });
- }
- }
- setTimeout(scrollSidebar, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement