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

position:fixed when element rect.top is 0 in body disables stickyClass #36

Open
kapouer opened this issue Oct 4, 2017 · 1 comment
Open

Comments

@kapouer
Copy link

kapouer commented Oct 4, 2017

sticky-js/src/sticky.js

Lines 253 to 262 in 0a0dca4

if (
element.sticky.rect.top === 0
&& element.sticky.container === this.body
) {
this.css(element, {
position: 'fixed',
top: element.sticky.rect.top + 'px',
left: element.sticky.rect.left + 'px',
width: element.sticky.rect.width + 'px',
});

prevents sticky-js from applying stickyClass.

It's easy to workaround that (by setting top:1px; position:relative;) but i don't see the point of that use case. Is it possible to remove it ?

@kkembel
Copy link

kkembel commented Sep 23, 2018

Agreed - this is an issue with our implementation. We used this library for a templated navbar that is sometimes transparent bg when at the top, then fades in when the stickyClass gets applied. But when the sticky element is placed at the top of the page, the stickyClass isn't applied as it should be - this library assumes that we meant to just do a fixed:0 position and disables the rest of the functionality.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants