Comments (8)
https://github.com/cferdinandi/smooth-scroll#fixed-headers
from smooth-scroll.
Ahh... don't know how I missed that :/ Thanks!
from smooth-scroll.
no worries. Happy to help!
from smooth-scroll.
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.
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.
@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.
@cferdinandi Awesome, I’ll check out the new version! :-)
from smooth-scroll.
You can still automatically get the height if you want, and use the offset to add additional padding.
from smooth-scroll.
Related Issues (20)
- not working on Firefox 70.0.1 / Ubuntu HOT 4
- Manual update: Scrolling to an anchor link on another page HOT 6
- Does not support special characters (ä,ö,å, etc.) HOT 1
- [Question] Draggable scrolling? HOT 3
- Offsetting for fixed header when coming from another page. HOT 2
- Polyfill for scroll-behavior? HOT 2
- Uncaught ReferenceError: SmoothScroll is not defined when compiling/minifying code into main scripts.min.js file HOT 2
- v16.1.1: Not published on npm! HOT 1
- Forgot console.log in last commit HOT 1
- Setting up auto offset HOT 9
- Scroll without #id_name on url HOT 1
- Focus is not adjusted when reduceMotion is enabled HOT 3
- Edge case issue - Failed to execute 'pushState' on 'History when linking to a from that has an input with name 'id' HOT 1
- overflow-y: scroll in css breaks smooth-scroll HOT 3
- Disable focus on options HOT 1
- Back button with header issue HOT 1
- Missing documentation step on how to import project via npm HOT 2
- Easing pattern documentation in source code is wrong
- Focus is not shifting properly when reduceMotion is enabled
- The event object is passed into the popHandler() function but not used
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smooth-scroll.