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

just-carousel

v1.1.0

Published

Just an 1-item-on-screen carousel that works naturally like an iOS/android desktops and nothing else.

Downloads

47

Readme

just-carousel

Just an 1-item-on-screen carousel that works naturally like an iOS/android desktops and nothing else.

An Example

Advantages

  • No dependencies.
  • 2.6kb gzip, 9.1kb full.
  • Android 4+, WP8+, iOS 7+.
  • Written on es3 so must work on most desktop browsers (only requires support for transform3d).
  • Easy integration with React, Vue, etc.
  • Unblocking UI (carousel reacts on any user action at any time). For example you can make 3 fast swype in a row.
  • Based on percent-layout. It means that change of device orientation is occurring fast, because doesn't recalculate any dimensions. Specially fine with responsive layout outside and inside of carousel.

Limitations

  • Supports only one slide on the screen at a time (but you can try to layout many items in each base slide).
  • No infinity mode (yet).
  • Doesn't have additional elements (like a prev/next arrows, cute little circles, etc). So you will have to do it yourself using api.
  • Doesn't react on mouse events.
  • You need to take care that all slides were the same height.

Thus, this carousel will suit you, if you just need a lightweight, simple, 1-item-on-screen touch-carousel.

Need something more? Try Swiper.

Install

$ npm install -S just-carousel

or oldschool method:

<script src="just-carousel.js"></script>

Usage

<div class="carousel">
	<ul> <!-- Root element must contain ul > li structure -->
		<li>1</li> <!-- li may contain anything -->
		<li>2</li>
		<li>3</li>
	</ul>
</div>
const justCarousel = require('just-carousel'); // ← if you use build system

const carousel = new JustCarousel({
	root: document.querySelector('.carousel'),
	onChangePos: function (data) {
		console.log(data); // {prevSlide, currentSlide}
	}
});

Options

root

Type: DOM Node
Required

A root element of carousel.

startIdx

Starting element.

duration

Type: number
Animation duration (milliseconds, default is 250)

timingFunction

Type: function
Animation timing function

/**
 * Default function is ease-out
 * @param {number} t — timing fraction (from 0 to 1)
 * @returns {number} — animation fraction
 */
function (t) {
	return t * (2 - t);
}

onChangePos

Type: function

Calls when the end of the animation. Accepts only object argument contains fields: prevSlide and currentSlide.

onMovingStart

Calls whenever any animation is started, including calling slideTo and user touch moving. Useful to optimize FPS (For example, you can stop video playing inside of slide when carousel animating.). Callback takes object with field currentSlide contains index.

onMovingEnd

Calls whenever any animation is stopped. Callback takes object with fields currentSlide and prevSlide contain indexes.

Instance methods

slideNext(), slidePrev()

slideTo(index<Number>)

update()

You can try to call it if something looks strange. it will recalculate some dimensions and reapply styles for slides.

destroy()

License

MIT © f0rmat1k

Special thanks to air-breathing.