Last active
August 29, 2015 14:03
-
-
Save jasesmith/0fd8d5196481c77d512e to your computer and use it in GitHub Desktop.
Revisions
-
jasesmith renamed this gist
Dec 3, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jasesmith renamed this gist
Oct 8, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jasesmith renamed this gist
Oct 8, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jasesmith renamed this gist
Oct 8, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jasesmith renamed this gist
Oct 8, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jasesmith revised this gist
Oct 8, 2014 . 3 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes.File renamed without changes. -
jasesmith renamed this gist
Oct 8, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jasesmith revised this gist
Oct 8, 2014 . 2 changed files with 3 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ Sticky Bar ----------------------------- Make an element sticky once it has scrolled out of view in a scrollable `<div>` -
jasesmith revised this gist
Aug 13, 2014 . 1 changed file with 7 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,8 @@ .bar { position: relative; } .sticky-bar .bar { position: fixed; left: 0; // or whatever makes it fit right: 0; // or whatever makes it fit } -
jasesmith revised this gist
Aug 13, 2014 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ .sticky-bar { .bar { position: fixed; left: 0; // or whatever makes it fit right: 0; // or whatever makes it fit } } -
jasesmith revised this gist
Aug 13, 2014 . 1 changed file with 10 additions and 9 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,19 +1,20 @@ var stickyBar = function(bar, pane) { var $body = $('body'), $bar = $(bar), $pane = $(pane), barHeight = $bar.outerHeight(true), $barParent = $bar.parent(), offset = $bar.offset().top - $pane.offset().top + barHeight; $pane.on('scroll', function() { var distance = $pane.scrollTop(); $body.toggleClass('sticky-bar', (distance > offset)); if($body.hasClass('sticky-bar')) { $bar.css({top: Math.floor($pane.offset().top)}); $barParent.css({paddingTop: barHeight}); } else { $bar.css({top: 0}); $barParent.css({paddingTop: 0}); } }); }; -
jasesmith created this gist
Jul 11, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ function stickyBar(bar, pane) { var $bar = $(bar), $pane = $(pane), barHeight = $bar.outerHeight(true), $barParent = $bar.parent(), offset = $bar.offset().top - $pane.offset().top + barHeight; $pane.on("scroll", function() { var distance = $pane.scrollTop(); $("body").toggleClass("sticky-bar", (distance > offset)); if(distance > offset) { $bar.css({top: $pane.offset().top}); $barParent.css({paddingTop: barHeight}); } else { $bar.css({top: 0}); $barParent.css({paddingTop: 0}); } }); }