Animate elements to and from display: none!
This plugin requires jQuery, and the jquery.trend.js plugin.
$('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.
We assume an inital default state of display: none
. Therefore the above classes should also include a display: block;
property.
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.
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);
To check if an element is currently visible, use the isVisible
function:
var visible = $('.el').revealer('isVisible');
.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;
}
}