Comments (2)
I think this is a bug in Firefox. I've encountered a similar issue when trying to scroll to the top element of the page which was offset by a margin. Firefox doesn't seem to take the top margin into account for determining the document.body.scrollHeight, causing ngSmoothScroll to stop scrolling prematurely due to the comparison:
(window.innerHeight + currentLocation) >= document.body.scrollHeight
At the start of the animation, when you have scrolled down almost all the way of the page, this comparison will be triggered incorrectly, because the document body scroll height is too little, causing ngSmoothScroll to stop the animation before it even started.
In Chrome this problem does not occur, as the margin is added correctly to the document body scroll height.
See this fiddle to see the problem (open it in Firefox and Chrome) and notice how in Firefox the scroll height is reported as 1000px, which is exactly the element's height, but excludes the margin (and body padding):
https://jsfiddle.net/xvbaoakg/
You can work around this problem by either commenting out the comparison in the smooth scroll library, or avoiding to use margins on your elements and add a padder element with padding instead.
from ngsmoothscroll.
Actually, just found a proper fix for this problem. Instead of using document.body.scrollHeight, use this to determine the correct document height:
var docHeight = Math.max(
Math.max(document.body.scrollHeight, document.documentElement.scrollHeight),
Math.max(document.body.offsetHeight, document.documentElement.offsetHeight),
Math.max(document.body.clientHeight, document.documentElement.clientHeight)
);
Updated fiddle: https://jsfiddle.net/xvbaoakg/1/
Will create a PR for this fix.
from ngsmoothscroll.
Related Issues (20)
- Error: [$injector:unpr] Unknown provider: smoothScrollProvider <- smoothScroll <- IndexCtrl HOT 2
- Having a hard time understanding the usage of this directive HOT 2
- Does not work with iOS
- Offset on end element using "scrollTo" directive HOT 1
- Avoiding form submit when used in submit button.
- scrollTo broken in min.js but working in .js HOT 13
- Documentation HOT 1
- smoothScroll as a service works in .js but not in min.js HOT 5
- Scrollspy or active state HOT 1
- unknown provider HOT 1
- scrolling not working HOT 12
- issues with bootstrap navbar toggle
- Scrolling cannot initiate when scroll position is at extreme bottom inside a container.
- Breaks scrolling with -webkit-overflow-scrolling: touch; on iOS
- Stop scroll bubbling
- scroll getting stuck at the bottom of the page
- How to add active class??
- scroll-to directive not working on touchscreen HOT 2
- Minified version didn't work HOT 2
- smoothScroll service not working for me
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 ngsmoothscroll.