Skip to content

Instantly share code, notes, and snippets.

@bchumney
Created October 31, 2013 17:33
Show Gist options
  • Save bchumney/7253756 to your computer and use it in GitHub Desktop.
Save bchumney/7253756 to your computer and use it in GitHub Desktop.
Sticky Columns in Convio Pages
$jq('.sticky').each(function(){
var sticky = $jq(this);
$jq(window).scroll(function(){
if ($jq(window).width() > 600) {
var t = $jq(sticky).parent().offset().top-20;
var b = $jq('#content').offset().top + $jq('#content').height();
var w = $jq(sticky).width();
var h = $jq(sticky).height();
if ($jq(window).scrollTop() < t) $jq(sticky).css({'width':'auto','position':'static'});
else if ($jq(window).scrollTop() >= t && $jq(window).scrollTop() < b-h) $jq(sticky).css({'width':w,'position':'fixed','top':'20px','bottom':'inherit'});
else if ($jq(window).scrollTop() >= b-h) {
$jq(sticky).css({'width':w,'position':'absolute','top':'inherit','bottom':'20px'});
if ($jq.browser.version == '7.0') $jq(sticky).css('top',$jq('#content').height()-h);
}
}
});
$jq(window).resize(function(){
if ($jq(window).width() < 601) {
$jq(sticky).css({'width':'auto','position':'static'});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment