Giter Site home page Giter Site logo

jhpratt / skrolr Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 2.0 144 KB

Lightweight JavaScript / TypeScript library that makes creating dynamic scrollers easy

License: GNU General Public License v3.0

CSS 6.23% JavaScript 57.92% HTML 2.64% Makefile 1.61% TypeScript 31.60%
css javascript scroller typescript

skrolr's People

Contributors

jhpratt avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

baytalov

skrolr's Issues

Is skrolr basic in its final form?

skrolr basic is currently only 605 bytes between the JS and CSS combined (402 JS, 203 CSS). I am certain the CSS cannot be further reduced, but am not sure if there are any hacky solutions to minify the JS further. At only 402 bytes, it is about as small as I can imagine it getting.

One way I could reduce the size (albeit slightly) is by changing the custom HTML attribute from data-skrolr to something else, although that would deviate from the skrolr prefixing I've been using to avoid conflicts.

For now, I will leave this issue open indefinitely pending feedback from anyone that happens to come across this (which is very few people at this point).

Sliding back, last element drops

If there are as many items in the list as there are being shown (the width), it causes the last element to drop when moving back.

Two possible solutions:

  1. Duplicate the entire list if less than width+1 items
  2. Don't remove element until animation is complete.

Solution 2 is the better solution, as it minimizes waste. However, I will likely implement solution 1, as it also avoid potential lazy-loading issues.

Go-to buttons at bottom

  • Determine if left/right is faster
  • Copy required number of elements to beginning/end
  • Transform with speed previously set
  • Remove all elements that were moved to beginning/end

Parameters to set height/width

Would eliminate need for parent element if a specific size is wanted.
Parameters:

  • height: #
  • width: #
  • size: w# h#

Size can be accomplished by splitting on space

Example:

document.getElementById("skrolr").skrolr({
    height: "200px",
    width: "500px"
    // size: "500px 200px"
});

Randomize order

As this is implemented with flexbox, this can be accomplished with the order property. An array can be initialized with length = numObjs. Iterate through objects, getting (and removing) that element from the array and setting it as the order property.

Scrolling by n elements

Able to do this by setting class variable, then forward() and backward() just need ±1 to be replaced with ±variable. This would inherently allow for RTL scrolling with negative values.

Stop scrolling when window is blurred

window.addEventListener( "focus", function() {...} );
window.addEventListener( "blur", function() {...} );

Just need to start/stop the interval.

Will also need a wasRunning variable that stores whether it was running before being blurred. Without this, it would start even if it wasn't running previously.

Can't click arrows while skrolr is active

Title. If skrolr is in the middle of a transition (as designated by data-skrolr-in-transition, it won't scroll when the arrows are clicked. Intended to prevent clicking multiple times (which causes errors of its own), but slightly overreaching.

Implement JS-based scrolling as backup

This will allow for greater compatibility with older browsers (that don't support CSS transitions). Should also add -webkit, -moz, and -o prefixes for compatibility.

Just adding prefixes allows support back to every browser released Apr. 2011 onwards. JS backup would allow it indefinitely (I think)

Dragging on mobile (with snap)

Minimal issue. This would put skrolr on par with other libraries that are out there, which combined with other features would (in my opinion) make it much better.

Honestly not sure how this will be implemented, as I haven't looked into it at all.

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.