GithubHelp home page GithubHelp logo

themes-lib-jquery.revealer's Introduction

jquery.revealer

Animate elements to and from display: none!

Requirements

This plugin requires jQuery, and the jquery.trend.js plugin.

Usage

$('button.show').on('click', function() {
  $('#my-element').revealer('show');
});

$('button.hide').on('click', function() {
  $('#my-element').revealer('hide');
});

$('button.toggle').on('click', function() {
  $('#my-element').revealer('toggle');
});

Revealer doesn't actually change your element's styles--instead it adds classes in an order that allows you to transition smoothly.

####.animating Apply your initial transition state (e.g. opacity: 0;) as well as your transition: property with this class.

####.visible Apply your final transition state (e.g. opacity: 1) to this state.

caveat

We assume an inital default state of display: none. Therefore the above classes should also include a display: block; property.

Different transitions on in and out

To apply different transitions for enter and leave, use .animating-in and .animating-out to declare different initial transition states. .visible will then include the final state for both in and out.

Setting a state without a transition

To skip the transitioning and force a specific display state, you may pass true as the second parameter to show, hide, or toggle:

$('.el').revealer('show', true);

Get the current state

To check if an element is currently visible, use the isVisible function:

var visible = $('.el').revealer('isVisible');

Example

.element-to-reveal {
  display: none;

  &.animating,
  &.visible {
    display: block;
  }

  // initial state for enter transition
  &.animating-in {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  // initial state for leave transition
  &.animating-out {
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  // final states for both in and out
  &.visible {
    transform: translateX(0);
    opacity: 1;
  }
}

Or some working code:

http://codepen.io/jnorth/pen/pJpGjj

themes-lib-jquery.revealer's People

Contributors

adamk-pxu avatar essmahr avatar jnorth avatar pixelmargaret avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.