_this.changeSlide(ltr, $slide, idx);
});
}
-
+
if (this.options.accessible) {
this.$wrapper.add(this.$bullets).on('keydown.zf.orbit', function(e) {
// handle keyboard event with keyboard util
* @fires Orbit#slidechange
*/
changeSlide(isLTR, chosenSlide, idx) {
+ if (!this.$slides) {return; } // Don't freak out if we're in the middle of cleanup
var $curSlide = this.$slides.filter('.is-active').eq(0);
if (/mui/g.test($curSlide[0].className)) { return false; } //if the slide is currently animating, kick out of the function
* @event Orbit#beforeslidechange
*/
this.$element.trigger('beforeslidechange.zf.orbit', [$curSlide, $newSlide]);
-
+
if (this.options.bullets) {
idx = idx || this.$slides.index($newSlide); //grab index to update bullets
this._updateBullets(idx);
if (this.options.closeOnClick && this.options.overlay) {
this.$overlay.off('.zf.reveal').on('click.zf.reveal', function(e) {
- if (e.target === _this.$element[0] ||
- $.contains(_this.$element[0], e.target) ||
- !$.contains(document, e.target)) {
- return;
+ if (e.target === _this.$element[0] ||
+ $.contains(_this.$element[0], e.target) ||
+ !$.contains(document, e.target)) {
+ return;
}
_this.close();
});
Foundation.Motion.animateIn(this.$overlay, 'fade-in');
}
Foundation.Motion.animateIn(this.$element, this.options.animationIn, () => {
- this.focusableElements = Foundation.Keyboard.findFocusable(this.$element);
- afterAnimationFocus();
+ if(this.$element) { // protect against object having been removed
+ this.focusableElements = Foundation.Keyboard.findFocusable(this.$element);
+ afterAnimationFocus();
+ }
});
}
// jQuery method of reveal
*/
_extraHandlers() {
var _this = this;
+ if(!this.$element) { return; } // If we're in the middle of cleanup, don't freak out
this.focusableElements = Foundation.Keyboard.findFocusable(this.$element);
if (!this.options.overlay && this.options.closeOnClick && !this.options.fullScreen) {
$('body').on('click.zf.reveal', function(e) {
- if (e.target === _this.$element[0] ||
- $.contains(_this.$element[0], e.target) ||
+ if (e.target === _this.$element[0] ||
+ $.contains(_this.$element[0], e.target) ||
!$.contains(document, e.target)) { return; }
_this.close();
});
* @return {jQuery} $focusable - all focusable elements within `$element`
*/
findFocusable($element) {
+ if(!$element) {return false; }
return $element.find('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]').filter(function() {
if (!$(this).is(':visible') || $(this).attr('tabindex') < 0) { return false; } //only have visible elements and those that have a tabindex greater or equal 0
return true;