Skip to content

Commit

Permalink
Fix if the bounded dom is not at the top of the bounder
Browse files Browse the repository at this point in the history
  • Loading branch information
Chan Shing Fai committed Jan 30, 2015
1 parent 5696ea9 commit ee6f03c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions js/jquery.floating-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

$.fn.floatingScroll = function($bounder, bounded){
var $that = this;
height_diff = $that.offset().top - $bounder.offset().top;
$bounder.addClass('floating-scroll-bounding-box');

return this.each(function(){
Expand All @@ -11,7 +12,7 @@
height_bounding = $bounder.height(),
height_content = $that.height();

if (pixel_depth > above_bounding) {
if (pixel_depth - height_diff> above_bounding) {
$that.addClass('floating-scroll-stick');
if(bounded != 'bounded'){
$bounder.height(height_content);
Expand All @@ -21,7 +22,7 @@
};

if (bounded == 'bounded'){
if (pixel_depth > above_bounding + height_bounding - height_content) {
if (pixel_depth - height_diff > above_bounding + height_bounding - height_content) {
$that.addClass('floating-scroll-stuck');
} else {
$that.removeClass('floating-scroll-stuck');
Expand All @@ -33,7 +34,6 @@
var pixel_depth = $(window).scrollTop();
relocate(pixel_depth);
});

});
};

Expand Down

0 comments on commit ee6f03c

Please sign in to comment.