wessberg / scroll-behavior-polyfill

A polyfill for the 'scroll-behavior' CSS-property
MIT License
102 stars 17 forks source link

scrollIntoView should default to block: "start" #10

Open randypuro opened 4 years ago

randypuro commented 4 years ago

I believe scrollIntoView should default to block: "start", but appears to be defaulting to block: "center". This causes behavior differences from browsers with the built-in helpers; and also means smooth scrolled anchor links are not scrolling to the same position as non-smooth scrolled anchor links.

wessberg commented 4 years ago

Hey there. Thanks for reporting this issue. I'll need to investigate this because the polyfill does in fact default to {block: "start", inline: "nearest"} for scrollIntoView as seen here: https://github.com/wessberg/scroll-behavior-polyfill/blob/0e4973c514f0fc713dbe6a617273c2ce1db29e42/src/patch/element/scroll-into-view.ts#L14

randypuro commented 4 years ago

Ahh, right. I think it's related only to to scrolling on anchor links then? They are partially determining the scrolling options from the scrolling container, and bypassing those defaults.

Then

https://github.com/wessberg/scroll-behavior-polyfill/blob/0e4973c514f0fc713dbe6a617273c2ce1db29e42/src/patch/element/compute-scroll-into-view.ts#L188

is effectively defaulting to block: "center"