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

yaslider

v0.2.3

Published

Yet Another Slider

Downloads

6

Readme

Yet Another Slider (yas)

Very simple slider written in TypeScript, easy to set up. Here some examples.


Use

The center idea is that the slider will be inserted in a HTMLElement node selected. The elements of the slider will be (by default) the children nodes of the selected node.

Without a package manager

You can download the project in the workspace and:

<!-- Import the styles needed. -->
<link rel="stylesheet" href="yas/style.css">

<!-- mark the node where the slider will be with an id -->
<div id="slider_id">
    <!-- Every child will be a slider item. -->
    <div> first child </div>
    <div> second child </div>
    <div> 
        <p> child with an image </p>
        <img src="./testImg.jpg" /> 
    </div>
</div>
<!-- Slide manually -->
<button onclick="mySlider.SlideLeft()">Prev</button>
<button onclick="mySlider.SlideRight()">Next</button>

<script type="module">
    import { AddYasToID } from './yas/slider.js'

    // Create the slider in the HTMLElement with `slider_id` as id
    window.mySlider = AddYasToID('slider_id');
</script>

The slider will have by default the elements that the node with id equal (in this case) to slider_id has as children.

The slider can be created using AddYasToHTMLElement, passing directly the container Node.

Remember to import the CSS code (yas/style.css).

With NPM

npm install yaslider

then

import { 
    AddYasToID,
    AddYasToHTMLElement,
    YaSlider } from 'yaslider/slider'

Actions

Action | Desctiption ---|--- ToogleAutoAnimation()| Start/Stop the auto change. Slide(direction)|Change the currentes elements in the selected direction. SlideRight()|Change the currentes elements in the right direction ( Slider(1) ). SlideLeft()|Change the currentes elements in the left direction ( Slider(-1) ).


Configuration

Method Chaining

let slider = AddYasToID('slider_id')
                .ChangeSpeedValues(10,0.5)
                .SetAmountOfElements(2)
                .SlowMovementOffset(100px)
                .SetSpecificAnimation("blur");

You can join the configurations chaining the methods when you create the slider using AddYasToID(), AddYasToHTMLElement() or initializing like new YaSlider()

Available configurations

Configuration | Description
--- | --- | SetSpeedValues(changeTime, endTime) | Sets the animation time, changeTime is the delay in seconds waited for change, and endTime is the delay of the change animation. SetAmountOfElements(amount) | Sets the number of items displayed at once. SetSlowMovementOffset(offset) | Sets the distance traveled by the elements after make a change, Ej: '100px'. SetAutoAnimationOff() | Remove auto change. SetSpecificAnimation(animation) | Sets a different animation. SetAnimationToEveryItem(ok) | Sets individual animation for every item. SetAutoAnimation(ok) | ShouldAutoMove?

We create some defaults animations like: default, opacity, up-down,blur and rotation, but the user can create their own animations following the structure defined by the animations in ./style.css.

Configuration object

You can configure the slider using a configuration object, using the methods AddYasToID() and AddYasToHTMLElement()

let slider=AddYasToID('slider_id',{
    amountElements:1,
    changeTime:2,
    startEndAnimationTime:0.8,
    initialAnimationDirection: 1,
    autoAnimation: true,
    slowMovementOffset: "20deg",
    animation:'rotation',
    animEveryItem: false 
})