Giter Site home page Giter Site logo

data-api support about scrollup HOT 8 OPEN

markgoodyear avatar markgoodyear commented on July 18, 2024
data-api support

from scrollup.

Comments (8)

markgoodyear avatar markgoodyear commented on July 18, 2024

@cemo As the scroll element is generated, I can't see an advantage of using data-api's. Are you thinking to be able to create your own element and use data-api?

from scrollup.

cemo avatar cemo commented on July 18, 2024

I was considering to add necessary data attributes to body and listen one with jquery.

from scrollup.

markgoodyear avatar markgoodyear commented on July 18, 2024

@cemo Do you have an example of how you could see this in action? I may add this into the roadmap, likely in v3.

from scrollup.

sergeyzwezdin avatar sergeyzwezdin commented on July 18, 2024

@markgoodyear The advantage of the data-api is no need to write JS-code at all to connect your plugin.

For example it could be like this —

<body data-scroll-up="300">

   <script ... />
</body>

Now you have to write small piece of JS to connect it.

So, I also agree that it's great feature to implement.

from scrollup.

markgoodyear avatar markgoodyear commented on July 18, 2024

The issue here is handling all the options, I can see two options after experimenting:

Option 1

<a class="scroll-up" title="Back to the top"
  data-scrollup="300"
  data-scrollup-speed="300"
  data-scrollup-easing="linear"
  data-scrollup-animation="fade"
  data-scrollup-animation-speed="200"
  data-scrollup-target=".some-elem-to-scroll-back-to">Text / Image / Icon</a>

So this would be a full data-api scenario, with data-attributes for every option. Allowing the user to include the actual markup on page, rather than the plugin inject it allows more control and less required options.

Option 2

<a class="scroll-up" title="Back to the top"
  data-scrollup='{
    "offset": 300,
    "scrollSpeed": 300,
    "easing": "linear",
    "animation": "fade",
    "animationSpeed": 200,
    "scrollTarget": ".some-elem-to-scroll-back-to"
  }'>Text / Image / Icon</a>

Similar to above, but using a single data-attribute and configuring via a JSON object inside.

The animation options may not even need to be there if we utilise CSS animations more.

What are your thoughts?

from scrollup.

cemo avatar cemo commented on July 18, 2024

Definitely first option will be my choice. IMHO the second one is mixing html with javascript which is pretty ugly.

from scrollup.

sergeyzwezdin avatar sergeyzwezdin commented on July 18, 2024

Agree with @cemo — first option is much better.

from scrollup.

markgoodyear avatar markgoodyear commented on July 18, 2024

Cool, thanks guys. This will probably wait until v3. I intend to re-write from scratch, dropping the need for jQuery. Hopefully try get it out in the next week, or at least a development version to test.

from scrollup.

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.