It looks like the header code calls the script. I’ve tried placing it in the body section and calling it (adding classes) to the element where I want to apply it to (a sidebar div) and haven’t had any luck.
Is this something pretty straight forward that I’m missing?
Hi there, without seeing the rest of project, I can only comment, but a couple of things:
a) You have this jquery.js code script being called. You can get rid of that, because webflow loads jquery for you.
b). You should put this remaining code in the Before Body tag section of the custom code tab in site settings, instead of in the head, you will have less issues doing that.
c) The container that you want to be made sticky, should have an ID of “sticker” according to your code fragment, so check that you are setting the ID of the element to “sticker” and not a class name of sticker, as this code above you pasted is identifying the element by ID, and not class. Elements that are referenced by css class name start with a period like “.sticker” not “#sticker”.
Just signed up this week and I’m wondering about this same thing. Is it possible to do this with the new Interactions, or is this example still the way to go?
Hi, well that is up to you, if you do this yourself in Webflow or something similar, you will have to in any case, set it up, and plan how you want it to work, setup the container at the top of the page with initial display set to none, and then fade in on scroll with fixed positioning of sticky content div to top of page (or where ever you want to pin the sticky container).
Sticky.js is just another third party solution, but you can do this with interactions and maybe a little jquery could be needed, depending on the customisation… You can use both methods though…
Thanks Dave. So I guess this is where I admit that Webflow is perfect for me because I have absolutely no clue how to deal with code at all. I poked around so that I didn’t have to look like an idiot, but I couldn’t find the answer. If I were to use sticky.js, where do I put that code? I understand that I have to use the code up in grandtheftpixel’s post in the Before Body tag section, but where do I put the actual jquery.sticky.js code and what do I do with the package.json file?
I realize I’m asking stupidly basic stuff here, so if there’s a resource somewhere else you’d like to point me to instead of having to answer these questions, I’m completely open to that.
Hi there, well if you want to use some custom js files like the sticky.js and the json file, then you need some kind of storage place for you to put those files, like for example you can use Amazon S3 or Rackspace to put files that can be publicly accessed via CDN.
So you would upload your js files to the CDN, then get a url pointing to those files, and link your scripts up (like the jquery.sticky.js file) using the script link:
You would place this script link in the Before BODY section of your site. If there are other files needed, like css files or something, you would link the CSS files in the HEAD section of your site.
Hello @Daniel_Remes, I’m not sure if I completely understand what the issue is that you are reporting, are you having an issue with this third-party plug-in? Are you having a padding issue with the sticky menu? What is the class name for the element that is using this sticky.js? Cheers
Ysr it’s the sticky.js. It’s working well and I have applied it in my tab menu (new widget) id: sticky and class "tab menu"but when I scroll and reach the top it makes the tab menu smaller and push it to the left.
Thanks so much for walking me through this @cyberdave! It’s working like a charm!
Unfortunately, my sticky element takes up a ginormous amount of space on a phone’s screen. Any idea how I’d go about disabling the sticky-ness on a phone? It’s tolerable on a tablet, phone? Notsomuch.
I got the sticky to work as it should. I have applied on a tab menu that sticks to the top when scrolled.
One problem occur tough thats a bit hard to figure out.
When using tabs and you are on the first tab and scrolling down to see the content and want to go to next tab, the content is scrolled down to the same level from the previous tab. Is there any way to fix this?
As a test, I have created a section with an ID of “sticker” and placed a coloured container inside… In preview mode this has no effect. my site is currently not published (unsure if this matters?) but if someone can look at this using the public link below, I would be very grateful:
Hi @Mark, you are correct, custom code will not work, until your site is published. You might try that, and then check it again. At that point, you can right click in chrome and choose inspect element, then go to your console tab, and check if there are any scripting errors.
Hi @Mark, I see lots of errors So you might check that, see my screenshot… My advice is to solve each error in turn, and then when there are no more errors, it should run ok hopefully
Yes Dave, as you said, fixing these was the answer. I uploaded the jquery.sticky.js file myself and that gave me a working URL reference. bower.json was not needed.
One slight additional problem, paragraph text seems to lighten as it sticks… any help on this would be awesome…