npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yascl

v1.6.1

Published

Minimalist endless carousel for extensive styling

Downloads

9

Readme

YASCL - Yet Another Simple Carousel Library

Pronounced Yaskel
Minimalist endless carousel

There's many great carousel JS libraries out there, but sometimes you just want a super-simple carousel which allows for extensive styling.

YASCL is perfect for that. It's about as plug-and-play as you can get.

Installation

Using npm:

npm install yascl

Then you can either use ES6 modules + a web bundler:

import YASCL from 'yascl';

or include the pre-bundled script:

<script type="text/javascript" src="node_modules/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="node_modules/yascl/dist/yascl.js"></script>

Using a CDN:

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/gwsmedia/yascl/dist/yascl.js"></script>

Usage

Simplest usage

new YASCL({
	selector: '#id-of-element'
});

Options

selector (required)
This is the CSS selector that will define the slider.
Unless innerSelector is also defined, this means:

  • All of its direct children will become slider items.
  • For looping to work smoothly the width of this container should at max be the width of one item less than the total width of all items. In other words if you have 5 items of width 100px, this container should have a max width of 400px.

The selector can map to multiple elements and they will all be instanstiated as separate sliders. The slide methods detailed below will apply to all of the sliders simultaneously, or one can use the getCarousel methods to get the inidividual carousels to call the methods on.

arrowSelector
This will define arrows that can be used to control the slider. It should be a CSS class that the next and previous arrows share. The previous arrow requires the class prev to differentiate it. The right class is now deprecated and functionality based on it will be removed in a further release.

time
default: 400
A number in miliseconds determining how long for one of the carousel items to make one full movement.

delay
default: 5000
A number in miliseconds determining how long the carousel will stay on an item before progressing.

easing
default: linear
The easing method of the animation. Can be swing or linear.

autoplay
default: false
The carousel will start automatically and continue moving. See reverse for changing the default direction.

reverse
default: false
By default, the carousel moves from the left slide to the right, or top to bottom if it is vertical. Setting this value to true will invert this. Often called rtl.

loop
default: false
Whether the carousel loops or not. If set to false, the carousel will hide the relevant arrow button once the beginning or end of the slider is reached.

draggable
default: true
Whether the carousel is draggable or not.

vertical
default: false
Whether the carousel is vertical or horizontal.

slideToEdge
default: false
Whether the slider will slide to the closest edge of the next item or not.
If false, the top/left edge of the next item will align with the top/left edge of the slider.
If true, the behaviour will remain the same when moving up/left, but when moving down/right the bottom/right edge of the next item will align with the bottom/right edge of the slider.

innerSelector
This is a CSS selector for an optional inner container if a more complex structure is desired. This means you can use selector to define a perimiter outside of which all slider content is hidden. Then you can use the innerSelector to define the inner boundaries of the slider which will be used to calculate where the slider should "begin" and "end". This means you can hide the arrows at a certain limit but still show the content overflowing out of innerSelector. If present, the bullet points defined for selector will apply to this container instead.

localArrows
default: false
If true, the arrowSelector will only be searched for as a descendent of selector. In such a case you will need to have an innerSelector defined so the arrows are not considered slider items. This can be useful if the arrows do not have unique arrowSelectors.

Methods

slideNext()
This can be used to slide the carousel(s) to the next item.

slidePrev()
This can be used to slide the carousel(s) to the previous item.

slideTo(slideNum)
This can be called to slide the carousel(s) to a specific item. Slide numbers begin at 0.
At the moment loop changes the slide numbers but this will be remedied in a future version.

Multiple carousels

The methods above will work regarldess as to how many elements selector maps to. However, there are times one may want to call a method on a singular carousel. In this case, one can use one of the methods below to get the individual carousel and apply said method to that instead.

getCarousels()
If selector refers to multiple elements, this method can be used to get all of the individual slider objects. Then the slide methods above can be called on specific carousels. If there is only one carousel, this is irrelevant.

getCarousel(index)
If selector refers to multiple elements, this method can be used to get a singular slider object. Then the slide methods above can be called on it directly. If there is only one carousel, this is irrelevant.

carouselCount()
This will get the number of carousels instantiated.

Example

var yascl = new YASCL({
	selector: '#page-wrapper .slider',
	time: 600,
	easing: 'swing',
	autoplay: true,
	arrowSelector: '.arrow'
});

yascl.slideTo(2);