acch/scrollpos-styler

Not working correctly when refreshing after scrolling

Closed this issue ยท 6 comments

Hey,

using v0.7. When page is already scrolled down and i'm refreshing it, 'sps--blw' class doesn't show up mots of the times and only sometimes does.
With v0.6 everything works as expected.
Tested on my mac with Chrome, Safari and Firefox - all behave the same.
Anyone else has this problem?

acch commented

Hi, thanks for your message. Can you confirm that the demo page works in your browser, but your own code doesn't?

Have you added the "classAbove" to your element in HTML? The default class name is sps--abv, so your HTML should look something like this:

<div class="sps sps--abv" ...>
  ...
</div>

If indeed you forgot to add the sps--abv class to your HTML then please don't close this issue, yet. I believe that this is a rather common mistake and I would want to add some code to circumvent such issues...

Please let me know how it goes - all the best!

You were right, I didn't add "classAbove" to my element, my mistake. Demo works properly. Although scrollpos-styler was working only with 'sps' class in v0.6. After adding the second class, everything works as it should. Thanks!

Im struggling with this.. Im a designer and new to scripts.
Here are two snippets what I have..
The css is imported.

Please help

<header> <div class="logo"> LOGO</div> <nav id="spy" class="sps sps--abv navbar navbar-expand-lg navbar-dark bg-primary" data-toggle="affix"> <a class="navbar-brand" href="#">Navbar</a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#chronicareNav" aria-controls="chronicareNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button>

At the bottom I have
`<script src="js/scrollPosStyler.js"></script>

`
acch commented

Hi @MichelleDiamond,

sorry for the late repsonse. Please check the usage section of the README and compare your code with the demo. If you're still having trouble then please open a new issue.

Thanks and all the best!

Hello,

the npm version is still 0.7.0 which does not include this fix.

Can you please publish to npm?

acch commented

@Reda You are absolutely right - I don't know how I could have missed that! Sorry, have just pushed a new version to npm.

https://www.npmjs.com/package/scrollpos-styler/v/0.7.1