Coder Social home page Coder Social logo

Comments (3)

stipsan avatar stipsan commented on July 23, 2024

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.

stipsan avatar stipsan commented on July 23, 2024

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:

from scroll-into-view-if-needed.

stipsan avatar stipsan commented on July 23, 2024

This is no longer an issue in v2

from scroll-into-view-if-needed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.