Giter VIP home page Giter VIP logo

Comments (4)

 avatar commented on July 20, 2024 1

Don't worry, can happen!
Ok, now it's totally clear.
Thanks again for you help, i'll do as you suggested!

from animated-scroll-to.

Stanko avatar Stanko commented on July 20, 2024

Hello @simarlab,

Library wasn't made to be used directly in a browser. You'll have to add a transpiler of some sort to make it happen.

For example for the demo page, I do exactly what you described above:
https://github.com/Stanko/animated-scroll-to/blob/v2/docs/docs.ts

but I then let TypeScript compiler generate plain javascript file that can be used in a browser:
https://github.com/Stanko/animated-scroll-to/blob/v2/docs/docs.js

Hope that helps, cheers!

P.S. Version 1 works directly in a browser:
https://github.com/Stanko/animated-scroll-to/tree/v1

from animated-scroll-to.

 avatar commented on July 20, 2024

@Stanko thanks for the fast reply, but you didn't gave me an answer on my question. Maybe I was confusing while explaining it. :)
I know the things you mentioned, and i'm using a webpack compiler to import library and then assigning it to the window in order to make it usable..and it's working perfectly.
What i would like to know if is possibile to edit the default configuration once or if i need to pass the values every time i call the method.
I hope to have explained better my issue, thanks for now!

from animated-scroll-to.

Stanko avatar Stanko commented on July 20, 2024

Oh, I have missunderstood your question, my bad, sorry 🙈

Unfortunately, at the moment there is no way to override default options globally.

You have to define your options and pass them in each call. To make things a little bit cleaner, you can wrap animateScrollTo in your own method like this:

const newDefaultOptions = {
  maxDuration: 1000,
  minDuration: 500,
};

function myScrollTo(elementOrPosition, userOptions) {
  // Allow to override the options
  const options = {
    ...newDefaultOptions,
    ...userOptions,
  }

  animateScrollTo(elementOrPosition, options);
}

Hope this time I answered the question 😄

from animated-scroll-to.

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.