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

me-show-transition

v3.0.5

Published

A highly customizable script to enable CSS transitions on toggle of the display property.

Downloads

26

Readme

meShowTransition

meShowTransition is a highly customizable script to enable CSS transitions on toggle of the display property.

Background

It is not possible to toggle the display property of an element (for instance from none to block) and apply transitions in one step. So many developers use opacity or similar properties to show/hide elements and be able to enhance user experience by applying fancy transitions.

But this leads to accessibility problems, because seemingly hidden elements are still available for screen-readers and can be focused by keyboard-navigation.

Usage

1. Include the JavaScript

Bundled & minified versions

meShowTransition depends on meTools.

It also uses Element.classList and Window.requestAnimationFrame, so you need to include a polyfill if you need to support IE9 (see http://caniuse.com/#feat=classlist and http://caniuse.com/#feat=requestanimationframe), which you can find at mePolyfills in the sources-folder.

  • Either include all the dependencies yourself and include me-show-transition.min.js from the dist folder in your HTML page.
  • or use one of the standalone bundles me-show-transition.bundle.min.js or me-show-transition.bundle.ie9.min.js.

Source versions

You can find the original JavaScript file in the src folder of this package.

AMD

meShowTransition has AMD support. This allows it to be lazy-loaded with an AMD loader, such as RequireJS.

2. Use meShowTransition

meShowTransition is initialized on the container you want to show/hide.

By default the widget will add the following classes to the container:

  • me-shown while the container is shown and ready for any transitions
  • me-show during the 'show' transition
  • me-hide during the 'hide' transition

Define your CSS transitions. For example:

#example-container.me-shown {
  transform: translate(0,0);
}
#example-container,
#example-container.me-hide {
  transition: transform .5s ease 0s;
  transform: translate(-100%,0);
}

Initialize meShowTransition

/**
 * Create a new instance
 * @param container mixed; id or element; the container in which the focus should be maintained
 * @param show boolean; optional; show the container immediately (without transitions) onInit; default is false
 * @param options object; optional; overwrite the default options
 */
var myShowTransition = new meShowTransition(container [,show] [,options])

To show the container, call

myShowTransition.show(); // show with transition
myShowTransition.show(true); // show immediately (without transition)

To hide the container, call

myShowTransition.hide(); // hide with transition
myShowTransition.hide(true); // hide immediately (without transition)

To destroy the instance, call

myShowTransition = myShowTransition.destroy();

Customize

Default options

{
  callbacks: { // false or fn(params); params = {container: CONTAINER,immediate:BOOL (immediate show/hide call - no transition)}
    beforeShow: false,
    beforeShowTransition: false,
    afterShowTransition: false,
    afterShow: false,
    beforeHide: false,
    beforeHideTransition: false,
    afterHideTransition: false,
    afterHide: false
  },
  transitionEndElement: false, // element to listen to the transitionend event on (default is the container); use this if you use transitions on more than 1 element on show/hide to define the element which ends the transitions
  transitionMaxTime: 500, // ms; timeout to end the show/hide transition states in case the transitionEnd event doesn't fire; set to 0 to not support transition
  indicators: { // classes added to mark states
    shown: 'me-shown', // set to the container as long as it is shown
    show: 'me-show', // set to the container during the show-transition
    hide: 'me-hide' // set to the container during the hide-transition
  }
}

Package managers

You can install meShowTransition using npm.

$ npm install me-show-transition

License

meShowTransition is licenses under the MIT licence.