Comments (4)
This looks more like a BrowserViewportScroller
issue rather than a Router one. scrollToElement
relies only on the internal offset and does not look at the styles on the element. There's no runnable reproduction in this report but I suspect if you provided a custom implementation that does that instead of what's here, it would work correctly.
from angular.
That would be the function that needs to change for this bug to be fixed.
And I call it out as a bug because intuitively the behavior of this scrollTo should match the native behavior of hashes. The scrollMargin css property exists precisely because of the sticky and fixed headers. The offset property can remain for backwards compatibility, but the properties need to be honored because that's why they exist. They are honored by all browsers except IE.
The below should work. I'll look into figuring out how to do a pull request over the weekend.
private scrollToElement(el: HTMLElement): void {
const rect = el.getBoundingClientRect();
const left = rect.left + this.window.pageXOffset;
const top = rect.top + this.window.pageYOffset;
const marginLeft = parseFloat(getComputedStyle(el).scrollMarginLeft);
const marginTop = parseFloat(getComputedStyle(el).scrollMarginTop);
const offset = this.offset();
this.window.scrollTo(left + marginLeft - offset[0], top + marginTop - offset[1]);
}
from angular.
Right, I agree.
They are honored by all browsers except IE
This, historically, would be the reason the issue exists. The implementation here has existed since before IE was dropped and potentially before the current set of browsers all fully supported it as well.
from angular.
This is the account that I will be issuing the PR from. I'll look up the guidelines and try to get something in on Saturday. I imagine test revision will be the largest segment.
from angular.
Related Issues (20)
- Unit Testing guide has incorrect code HOT 1
- Angular compiler seemingly false negative warning : optional chaining refused on array item HOT 3
- ActivatedRoute in Directive: Snapshot.params are not getting updated HOT 2
- APP_INITIALIZER with HttpClient provoke memory leak in SSR projects HOT 8
- New Angular Docs website is not PWA compatible
- @for can't be used for forms where $index based calls on removeAt() are necessary HOT 1
- Recording already in progress issue in Profiler
- SSR won't render [style.background-image] with base64 URL values
- Btter Docs About Error handling in httpClient HOT 2
- No compile time error/warning in HTML template when Signals variable used without parenthesis HOT 2
- Fail to load docs HOT 1
- We couldn't start the tutorial app. HOT 2
- ngProjectedAs not working when used as static host property inside @Component
- "Could not resolve dependency" for ts version in webcontainers at adev HOT 1
- ESBuild not calling any http request in server side HOT 2
- Unable to hydrate nested anchor elements HOT 3
- Broken links on ng-template reference page HOT 1
- [tour-of-heroes/toh-pt1][Format with the UppercasePipe] adding pipe {{hero.name | uppercase }} requires "CommonModule" HOT 1
- fetch resulting in respons.json already parsed error HOT 2
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 angular.