Skip to content

Commit

Permalink
Element.Pin - Checking for pin_scrollFixer is enough to know if the e…
Browse files Browse the repository at this point in the history
…lement is pinned by JS or with position: fixed
  • Loading branch information
arian committed Oct 8, 2010
1 parent 08cb6f1 commit 351b719
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Source/Element/Element.Pin.js
Expand Up @@ -41,7 +41,7 @@ provides: [Element.Pin]
supportTested = true;
}

if (this.getStyle('display') == 'none') return null;
if (this.getStyle('display') == 'none') return this;

var pinnedPosition,
scroll = window.getScroll();
Expand Down Expand Up @@ -79,7 +79,6 @@ provides: [Element.Pin]
});
}.bind(this);

this.store('pin:_pinnedByJS', true);
this.store('pin:_scrollFixer', scrollFixer);
window.addEvent('scroll', scrollFixer);
}
Expand All @@ -95,15 +94,16 @@ provides: [Element.Pin]
pinnedPosition = this.getPosition(offsetParent);

this.store('pin:_pinned', false);
if (!this.retrieve('pin:_pinnedByJS')){
var scrollFixer = this.retrieve('pin:_scrollFixer');
if (!scrollFixer){
this.setStyles({
position: 'absolute',
top: pinnedPosition.y + scroll.y,
left: pinnedPosition.x + scroll.x
});
} else {
this.store('pin:_pinnedByJS', false);
window.removeEvent('scroll', this.retrieve('pin:_scrollFixer'));
this.store('pin:_scrollFixer', null);
window.removeEvent('scroll', scrollFixer);
}
this.removeClass('isPinned');
}
Expand Down

0 comments on commit 351b719

Please sign in to comment.