Created
March 1, 2012 04:56
-
-
Save ardianzzz/1947391 to your computer and use it in GitHub Desktop.
xy page
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
<script> | |
$(function () { | |
var msie6 = $.browser == 'msie' && $.browser.version < 7; | |
if (!msie6) { | |
var top = $('#hot-cat').offset().top - parseFloat($('#hot-cat').css('margin-top').replace(/auto/, 0)); | |
$(window).scroll(function (event) { | |
// what the y position of the scroll is | |
var y = $(this).scrollTop(); | |
// whether that's below the form | |
if (y >= top) { | |
// if so, ad the fixed class | |
$('#hot-cat').addClass('fixed'); | |
} else { | |
// otherwise remove it | |
$('#hot-cat').removeClass('fixed'); | |
} | |
if (y >= top) { | |
// if so, ad the fixed class | |
$('html').addClass('scrolled'); | |
} else { | |
// otherwise remove it | |
$('html').removeClass('scrolled'); | |
} | |
}); | |
} | |
}); | |
</script> | |
<scripb> | |
//scroll-effect-function | |
var msie6 = $.browser == 'msie' && $.browser.version < 7; | |
if (!msie6) { | |
var top = $('#hot-cat').offset().top - parseFloat($('#hot-cat').css('margin-top').replace(/auto/, 30)); | |
$(window).scroll(function (event) { | |
// what the y position of the scroll is | |
var y = $(this).scrollTop(); | |
// whether that's below the form | |
if (y >= top) { | |
// if so, ad the fixed class | |
$('body').addClass('body-scroll'); | |
} else { | |
// otherwise remove it | |
$('body').removeClass('body-scroll'); | |
} | |
}); | |
} | |
var $win = $(window) | |
, $nav = $('.subnav') | |
, navTop = $('.subnav').length && $('.subnav').offset().top - 40 | |
, isFixed = 0 | |
processScroll() | |
// hack sad times - holdover until rewrite for 2.1 | |
$nav.on('click', function () { | |
if (!isFixed) setTimeout(function () { $win.scrollTop($win.scrollTop() - 47) }, 10) | |
}) | |
$win.on('scroll', processScroll) | |
function processScroll() { | |
var i, scrollTop = $win.scrollTop() | |
if (scrollTop >= navTop && !isFixed) { | |
isFixed = 1 | |
$nav.addClass('subnav-fixed') | |
} else if (scrollTop <= navTop && isFixed) { | |
isFixed = 0 | |
$nav.removeClass('subnav-fixed') | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment