Code Monkey home page Code Monkey logo

Comments (8)

cferdinandi avatar cferdinandi commented on September 28, 2024

https://github.com/cferdinandi/smooth-scroll#fixed-headers

from smooth-scroll.

Cam avatar Cam commented on September 28, 2024

Ahh... don't know how I missed that :/ Thanks!

from smooth-scroll.

cferdinandi avatar cferdinandi commented on September 28, 2024

no worries. Happy to help!

from smooth-scroll.

arielsalminen avatar arielsalminen commented on September 28, 2024

Would it be possible to define this by hand instead of automatically getting the height? I think it would be much more useful as many times you might want to manually adjust the offset to leave more white space or something like that.

Also, the problem with the current implementation is that it calculates the wrong height under certain circumstances, so I had to change the code so that I could manually enter the pixel amount I want: https://github.com/adtile/fixed-nav/blob/master/js/scroll.js#L127 (here's the live demo: http://www.adtile.me/fixed-nav/)

So my question is, should this actually be an option in smoothScroll so that you could manually define it? Think it would be more helpful than the current implementation. Just a fast example below on what I mean:

smoothScroll.init({
    speed: 500, // How fast to complete the scroll in milliseconds
    easing: 'easeInOutCubic', // Easing pattern to use
    offsetMargin: 302, // Negative or positive margin that is added or removed from the offset scroll location
    updateURL: false, // Boolean. Whether or not to update the URL with the anchor hash on scroll
    callbackBefore: function ( toggle, anchor ) {}, // Function to run before scrolling
    callbackAfter: function ( toggle, anchor ) {} // Function to run after scrolling
});

This way, if it was part of the options object, you would also be able to manually change it between different media query breakpoints if needed.

I could also implement this/do a pull if you think this is something we could consider adding. :-)

from smooth-scroll.

cferdinandi avatar cferdinandi commented on September 28, 2024

Hi @Cam - I plan on adding an offset option, but that will only add additional padding to the auto-measurement it takes. If you'd prefer to enter it on your own, the solution today would be to manually call the animateScroll function in your own script. https://github.com/cferdinandi/smooth-scroll#use-smooth-scroll-events-in-your-own-scripts

from smooth-scroll.

cferdinandi avatar cferdinandi commented on September 28, 2024

@viljamis - I just pushed version 4.5, which adds offset as an option both in the init call and as a link-by-link override. Cheers!

from smooth-scroll.

arielsalminen avatar arielsalminen commented on September 28, 2024

@cferdinandi Awesome, I’ll check out the new version! :-)

from smooth-scroll.

cferdinandi avatar cferdinandi commented on September 28, 2024

You can still automatically get the height if you want, and use the offset to add additional padding.

from smooth-scroll.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.