Skip to content
This repository has been archived by the owner on Jan 20, 2021. It is now read-only.

Commit

Permalink
fixes #24
Browse files Browse the repository at this point in the history
  • Loading branch information
yairEO committed Sep 17, 2016
1 parent f53077d commit 220c5d1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions stickyfloat.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
});

$(w).on('resize.sticky', function(){
raf( that.rePosition.bind(that) )
raf( $.proxy(that.rePosition, that) )
});
});
// for every element, attach it's instanced 'sticky'
Expand Down Expand Up @@ -113,7 +113,7 @@

if( maxTopPos < 0 )
maxTopPos = 0;

// Define the basics of when should the object be moved
pastStartOffset = areaScrollTop > settings.startOffset; // check if the window was scrolled down more than the start offset declared.
objFartherThanTopPos = $obj.offset().top > (settings.startOffset + settings.offsetY); // check if the object is at it's top position (starting point)
Expand All @@ -123,10 +123,10 @@
// the top position possible (+ offsetY) AND window size must be bigger than Obj size
if( ((pastStartOffset || objFartherThanTopPos) && !objBiggerThanArea) || force ){
this.newpos = areaScrollTop - settings.startOffset + settings.offsetY;

if( settings.stickToBottom )
this.newpos += this.areaViewportHeight - this.stickyHeight - settings.offsetY * 2;

// made sure the floated element won't go beyond a certain maximum bottom position
if( this.newpos > maxTopPos && settings.lockBottom ){
this.newpos = maxTopPos;
Expand All @@ -140,9 +140,9 @@
// if window scrolled < starting offset, then reset Obj position (settings.offsetY);
else if( areaScrollTop < settings.startOffset && !settings.stickToBottom )
this.newpos = settings.offsetY;

$obj.toggleClass('sf--active', setActive);

// if duration is set too low OR user wants to use css transitions, then do not use jQuery animate
if( duration < 5 || (settings.cssTransition && supportsTransitions) )
$obj[0].style.top = this.newpos + 'px';
Expand Down

0 comments on commit 220c5d1

Please sign in to comment.