Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adding a hook for when show animation completes #42

Open
wants to merge 2 commits into from

1 participant

@mbriggs

Hi guys,

I had a form in a reveal dialog where I wanted to focus on the first input, but you can't do that when the dialog is not on the screen. So I made the dialog emit a "reveal:visible" event when the animation is completed.

@mbriggs

Needed a close hook as well, so added a reveal:close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 24, 2012
  1. @mbriggs
Commits on Jan 27, 2012
  1. @mbriggs
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 6 deletions.
  1. +15 −6 jquery.reveal.js
View
21 jquery.reveal.js
@@ -28,7 +28,15 @@
topMeasure = parseInt(modal.css('top')),
topOffset = modal.height() + topMeasure,
locked = false,
- modalBg = $('.reveal-modal-bg');
+ modalBg = $('.reveal-modal-bg'),
+ openAnimationComplete = function() {
+ modal.trigger('reveal:visible');
+ unlockModal();
+ },
+ closeAnimationComplete = function() {
+ modal.trigger('reveal:hidden');
+ unlockModal();
+ }
if (modalBg.length == 0) {
modalBg = $('<div class="reveal-modal-bg" />').insertAfter(modal);
@@ -46,19 +54,19 @@
modal.delay(options.animationSpeed / 2).animate({
"top": $(document).scrollTop() + topMeasure + 'px',
"opacity": 1
- }, options.animationSpeed, unlockModal);
+ }, options.animationSpeed, openAnimationComplete);
}
if (options.animation == "fade") {
modal.css({'opacity': 0, 'visibility': 'visible', 'top': $(document).scrollTop() + topMeasure});
modalBg.fadeIn(options.animationSpeed / 2);
modal.delay(options.animationSpeed / 2).animate({
"opacity": 1
- }, options.animationSpeed, unlockModal);
+ }, options.animationSpeed, openAnimationComplete);
}
if (options.animation == "none") {
modal.css({'visibility': 'visible', 'top': $(document).scrollTop() + topMeasure});
modalBg.css({"display": "block"});
- unlockModal();
+ openAnimationComplete();
}
}
modal.unbind('reveal:open', openAnimation);
@@ -75,7 +83,7 @@
"opacity": 0
}, options.animationSpeed / 2, function () {
modal.css({'top': topMeasure, 'opacity': 1, 'visibility': 'hidden'});
- unlockModal();
+ closeAnimationComplete();
});
}
if (options.animation == "fade") {
@@ -84,12 +92,13 @@
"opacity" : 0
}, options.animationSpeed, function () {
modal.css({'opacity': 1, 'visibility': 'hidden', 'top': topMeasure});
- unlockModal();
+ closeAnimationComplete();
});
}
if (options.animation == "none") {
modal.css({'visibility': 'hidden', 'top': topMeasure});
modalBg.css({'display': 'none'});
+ closeAnimationComplete();
}
}
modal.unbind('reveal:close', closeAnimation);
Something went wrong with that request. Please try again.