Giter Club home page Giter Club logo

scroll-snap-carousel's Introduction

Snap scroll carousel

"Classical" carousels huge libraries could be easily replaced by native scroll functionality

  • that would contribute to grater UX, better performance and progressive enhancement practice.

You probably know that scroll is very complex functionality that very hard to implement without access to native OS API. That's why native scroll is more comfortable for the user (on modern desktop and mobile) than any point-and-click functionality.

CSS snap points

But in classical "carousels", you are expected some snapping of scrolling. And it could be done with CSS.

It has been 3 years or so when this API available for browsers.

Features

  • Progressive enhancement, basic funtionality available without JS
  • Responsive
  • LTR and RTL directions support
  • Plays well with dynamic content
  • AAA ARIA accessibility (focus of elements and visibility for AT)
  • Could be controlled from keyboard (tab, arrows), mouse, touch etc. without any JS logic (Chrome has bug with arrows navigation)
  • Scroll up to all elements, not just 1 at the time

Infinite scrolling

It is hard to explain why this marquee-like pattern even needed in carousels.

Since carousels mostly represents large lists user should have feels of extremes of the list. For that type of content more important good browsing UX than "auto scrolling".

Browser compatibility

As progressive enhancement supports in every browsers from Netscape navigator 1.0 to latest Firefox.

Progressive enhancement and graceful degradation:

  1. if no JS available it would be just native scroll;
  2. if scroll snap CSS API available it would be snapped to declared values;
  3. if JS and snap scroll available than user will have Buttons and pagination functionality improvements over native scroll.

With polyfill tested:

  • FF (68.0), Chrome (75.0.3770.142) Linux
  • FF (68.0), Chrome (75.0.3770.142) MacOS

Note! Each OS and OS preferences resulted on different, but always familiar scroll behavior.

Safari 12.1.1 not work smooth scroll (could be polyfiled) Edge not work smooth scroll 11 not work smooth scroll

License

MIT D.Nechepurenko 2020

scroll-snap-carousel's People

Contributors

dimanech avatar

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.