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

expander.js

v1.0.2

Published

Simple html item expander

Downloads

12

Readme

expander.js

This package makes your HTML elements increase and decrease in an animated way. The best features are toggle elements, increase element, decrease element and reset elements.

This package is still in development. I welcome suggestions for changes that will bring it closer to compliance without overly complicating the code, or useful test cases to add to the test suite.

Contents

Features

Install

npm install expander.js

Usage

1. Add markup (your wrapper has to be relative position and add hidden style as display none)

<style>
  .hidden
   {
    display: none;
   }
  .cs-expander-items
  {
    position: relative;
  }
</style>
<div class="cs-expander">
    <div class="cs-expander-items">
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
        <div class="item"></div>
    </div>
</div>

2. Initialize your class

<script src="expander.js/dist/expander.js"></script>
<script>
    let expander = new Expander('.cs-expander-items',{toggle:true,resetable:true})
</script>

Options

| Option | Type | Description | | --- | --- | --- | | show | Number | Default: 4. Number of items initially shown. | | increase | Number | Default: 3. Number of items to add per click. | | decrease | Number | Default: 3. Number of items to remove per click, if it is zero it will use increase variable. | | toggle | Boolean | Default: false. Append a toggle button, and functionality. | | resetable | Boolean | Default: false. Append a reset button, and functionality. | | unary | Boolean | Default: false. Removes increase and decrease buttons if toggle is true | | increaseBtn | String | Default: '.cs-expander-increase-btn'. Button container for increasing items | | increaseBtnValue | String | Default: 'Increase Items'. Increase button text | | toggleBtn | String | Default: '.cs-expander-toggle-btn'. Button container for toggling | | toggleBtnValue | String | Default: 'Toggle Items'. Toggle button text | | decreaseBtn | String | Default: '.cs-expander-decrease-btn'. Button container for decreasing items | | decreaseBtnValue | String | Default: 'Decrease Items'. Decrease button text | | resetBtn | String | Default: '.cs-expander-reset-btn'. Button container for reset expander | | resetBtnValue | String | Default: 'Collapse'. Reset button text | | animationDuration | Number | Default: 1. Animation Duration |

Methods

The slider returns a slider object with some properties and methods once it's initialized:

{
  collapse: collapse(),
  increaseItem: increaseItem(),
  decreaseItem: decreaseItem(),
  getActiveItems: getActiveItems, // Array
  getHiddenItems: getHiddenItems, // Array
}

collapse

Resets expander

expander.collapse();

increaseItem, decreaseItem

Increase or decrease items by number or default.

expander.increaseItem();
expander.increaseItem(5);

expander.decreaseItem();
expander.decreaseItem(5);

getActiveItems

Get all shown elements as an node array

expander.getActiveItems();

getHiddenItems

Get all hidden elements as an node array

expander.getHiddenItems();

License

This project is available under the MIT license.