Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

carousel-lite

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

carousel-lite

Touch friendly. Incredibly small. Carousels the native way.

  • 0.1.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by180%
Maintainers
1
Weekly downloads
 
Created
Source

Touch friendly. Incredibly small. Carousels the native way.

Carousel Lite aims to provide the most simple carousel solution possible. With a very small amount of code, we can hijack the default scroll behavior of an overflowed list (which provides us the added benefit of touch support with no additional JS - see below).

carousel.register( args );

Must provide the following arguments:

Selector for carousel ul

items

Selector for li children of the carousel ul

next

Selector for next button

previous

Selector for previous button

Nothing more is needed than a simple list:

<ul>
    <li></li>
    <li></li>
    <li></li>
</ul>
ul {
    overflow: hidden;
    white-space: nowrap;
}

li {
    display: inline-block;
}

Next/Previous Markup

The elements that you choose for your next/previous buttons can be anything, but here is an example:

<button class="previous"></button>
<button class="next"></button>

Next/Previous Styles

When the previous or next button is disabled (the carousel is at the beginning or end of a list, respectively), carousel-button-disabled is added to its class list (the disabled attribute is also toggled, but is only relevant if you are using button elements for next/previous). You can use this to style the buttons appropriately.

When a carousel is registered, the previous button is automatically disabled. The next button is disabled as well if the entirety of list fits within the carousel's clientWidth.

Optional Styles

To fall back on native touch scroll interaction for mobile devices, add in a media query like this:

@media (max-width: 640px) {
    button {
        display: none;
    }

    ul {
        overflow: auto;
    }
}

Keywords

FAQs

Package last updated on 05 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc