Comments (3)
You are right the interface have turned messy as functionality got added.
I've just finished setup semantic-release
on this project to make it easier to do new releases.
Next on my list is to setup a simple testing suite using SauceLabs to get good browser coverage to prevent regressions and to catch bugs.
After that I intend to refactor the API signature and update the docs.
The new signature will be much simpler. Something like:
export interface AnimationOptions {
duration?: number;
easing?: 'ease' | 'easeIn' | 'easeOut' | 'easeInOut' | 'linear' | Function;
step?: Function;
done?: Function;
}
export interface ScrollIntoViewIfNeededOptions {
centerIfNeeded?: boolean;
boundary?: Element;
animate?: boolean | AnimationOptions;
}
export default function(
node: Element,
options?: boolean | ScrollIntoViewIfNeededOptions
): void;
So if you pass a boolean as the second argument you get the same behavior as in browsers that have the native implementation. Pass an object and you can customise it 😄
If you pass true
to options.animate
it'll use the default animation settings, or pass an object with options and it counts as true. By default it's false.
from scroll-into-view-if-needed.
The reason why the second argument exists is because it exists in the native implementation: https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoViewIfNeeded
And I didn't think about toggling between a boolean for backwards compatibility and an object with options for convenience. I regret that now 🙂
However it is confusing indeed. Work is done to make these features part of the scrollIntoView spec:
- https://drafts.csswg.org/cssom-view/#dom-element-scrollintoview
- https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView#scrollIntoViewOptions
from scroll-into-view-if-needed.
This is no longer an issue in v2
from scroll-into-view-if-needed.
Related Issues (20)
- [BUG] Safari on macOS Monterey 12.3.1
- "Cannot use import statement outside a module" error when using v2.2.31 HOT 1
- Dealing with a Fixed Navbar HOT 2
- "export 'default' (imported as 'compute') was not found in 'compute-scroll-into-view' HOT 1
- t.scroll is not a function HOT 1
- [TS] typedoc TS1479 error HOT 8
- scrollIntoView does not work anymore for element in shadow dom
- something is wrong with the [email protected] project HOT 11
- scroll position error with `display: none;` element HOT 1
- Add an options to skip in document check or pass a new `document`
- Body behind the modal scrolls HOT 1
- Snaps instead of scrolling smoothly. HOT 2
- Unneeded scrolling of ancestors HOT 1
- how to know when scrolling is complete?
- Does not scroll to element in iframe outside viewport HOT 2
- How can I combine behavior function and behavior smooth
- Shadow DOM support? HOT 2
- Dependency Dashboard
- Scroll horizontally only inside a specific div HOT 1
- Horizontal RTL scrolling goes wrong way HOT 5
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 scroll-into-view-if-needed.