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

simply-slide

v0.0.7

Published

simple and decoupled slide show with basic animation and touch controls

Downloads

9

Readme

Introduction

Simply Slide is a simple slider that brings with the very basic to customize your slide show it comes with some nice utilities that allows to enhance the user experience with touch sliding, image resize interaction, optional direction buttons, add new slides in run time and color customization.

how to install:

NPM package compatibility with CommonjS and ESModules;

npm i simply-slide

yarn add simply-slide

Then in your use it depending the format better fit to your needs.

#### CommonJS

const simplySlide = require("simply-slide");

simplySlide.setSlider({
  node: document.querySelector("#slider1")
})

ESModule

import { setSlider } from "simply-slide";

setSlider({
  node: document.querySelector("#slider1")
})

CSS available to use with webpack

// esm
import "simply-slide/dist/simply-slide.css";

// cjs
require "simply-slide/dist/simply-slide.css";

UMD with npm package

// Javascript
https://unpkg.com/[email protected]/dist/simply-slide.js

// CSS
https://unpkg.com/[email protected]/dist/simply-slide.css

This is an example using UMD with html

<!DOCTYPE html>
<html lang="en">
	<head>
		<title>Simply slide</title>
		<link
			rel="stylesheet"
			href="https://unpkg.com/[email protected]/dist/simply-slide.css"
		/>
	</head>
	<body>
		<div class="slider" id="slider1">
			<div class="slider__container">
				<div class="slider__slide"><span>1</span></div>
				<div class="slider__slide"><span>2</span></div>
				<div class="slider__slide"><span>3</span></div>
			</div>
		</div>

		<script src="https://unpkg.com/[email protected]/dist/simply-slide.js"></script>
		<script>
			document.addEventListener("DOMContentLoaded", function (event) {
				simplySlide.setSlider({
					node: document.getElementById("slider1"),
				});
			});
		</script>
	</body>
</html>

How to use it

Simply Slide is compatible with all of the current Frontend frameworks, web components and vanilla JS. since this is a tools that facilitate the skeleton for the slideshow you can use how you want.

First create the slide using html

Use the building blocks to set the basic skeleton for your slide

use the class .slider to define the slider and the styles for the entire element. all of these are mandatory and they where thought not only as easy to define styles but to be easy to read and simplify the reading of the slider.

define the slider__container and the basic slides. each one with the class slider__slide

<div class="slider" id="slider1">
	<div class="slider__container">
		<div class="slider__slide"><span>1</span></div>
		<div class="slider__slide"><span>2</span></div>
		<div class="slider__slide"><span>3</span></div>
	</div>
</div>

Then set the slider

<script>
	document.addEventListener("DOMContentLoaded", function (event) {
		simplySlide.setSlider({
			node: document.getElementById("slider1"),
		});
	});
</script>

Here a really basic example with the basic building blocks.

Notice that inside the slides theres nothing. this is made by design. you can customize every slide content as you wish.

Basic Example

CSS Class Utilities

Use the slider__slide__image

This utility is a great complement to your contents that contain images. the utility class enrich the images with a resize when the user touch or clicks on the slide.

Really good for UX interaction.

Images example

Use the slider__slide-centered

With this class you could center the content of the slide. it uses flexbox with justify-content and align-items to center.

Use this class utils with the slide directly

<div class="slider" id="slider1">
	<div class="slider__container">
		<div class="slider__slide slider__slide-centered"><span>1</span></div>
		<div class="slider__slide slider__slide-centered"><span>2</span></div>
		<div class="slider__slide slider__slide-centered"><span>3</span></div>
	</div>
</div>

Basic example centered

You can change some parameters of the slider

import { setSlider } from "simply-slide";

setSlider({
  node: document.querySelector("#slider1")
  shouldDisableContextMenu: false // false by default. it shows the browser context menu.
  hasDirectionsButton: true, // true by default. it shows the direction buttons.
	controlsColor: "#3335", // change the color of the direction buttons.
	directionIconColor: "#efefef // change the color of the button icon.
})

Look a these example to see the configuration in action. try to right click on the slider. In these examples the context menu are disabled.

Example with context menu disabled

Customized slide show

Add more slides dynamically

Once define your slide with setSlide it returns and instance of the slide where you can have access to extra functionalities in run time.

so far there is just one functionality; addLazy(DOMElement) which you could use to add new slides dynamically with out the need to re render the entire slide.

import { setSlider } from "simply-slide";

const newSlide = document.createElemnent(div)
newSlide.classList.add("slider__slide")
newSlide.innerHTML = "<span>4</span>"

const slider = setSlider({
  node: document.querySelector("#slider1")
})

setTimeout(() => {
  slider.addLazy(newSlide)
}, 3000)

You can see this feature in action in this blog template example.

Notice that you have some images in the slider in the beginning, when you click in the get more images it adds more images dynamically.

Add images dynamically

License

MIT

Copyright (c) 2013-present, Yuxi (Evan) You