Skip to content

Commit

Permalink
Add onOpenComplete event
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanWagner committed Apr 22, 2021
1 parent 5d2e3d4 commit e4bd887
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/js/jBox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ declare namespace jBox {
/** Fired when jBox opens */
onOpen?: () => void;

/** Fired when jBox is completely open (when fading is finished) */
onCloseComplete?: () => void;

/** Fired when jBox closes */
onClose?: () => void;

Expand Down
6 changes: 6 additions & 0 deletions src/js/jBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ function jBoxWrapper(jQuery) {
onPosition: null, // Fired when jBox is positioned
onCreated: null, // Fired when jBox is created and availible in DOM
onOpen: null, // Fired when jBox opens
onOpenComplete: null, // Fired when jBox is completely open (when fading is finished)
onClose: null, // Fired when jBox closes
onCloseComplete: null, // Fired when jBox is completely closed (when fading is finished)
onDragStart: null, // Fired when dragging starts
Expand Down Expand Up @@ -798,6 +799,7 @@ function jBoxWrapper(jQuery) {
var translate = position ? item[1].replace('%XY', this._getXY(position).toUpperCase()) : item[1];
animations[this.options.animation[ev]].positions && (translate = translate.replace('%V', animations[this.options.animation[ev]].positions[position][item[0]]));
keyframe_css += item[0] + ' {transform:' + translate + ';}';

}.bind(this));
keyframe_css += '}';

Expand Down Expand Up @@ -1744,6 +1746,9 @@ function jBoxWrapper(jQuery) {
this.isOpening = true;
this.wrapper.css({display: 'block'});
}.bind(this),
complete: function () {
this._fireEvent('onOpenComplete');
}.bind(this),
always: function () {
this.isOpening = false;

Expand All @@ -1754,6 +1759,7 @@ function jBoxWrapper(jQuery) {
} else {
this.wrapper.css({display: 'block', opacity: 1});
this.positionOnFadeComplete && this.position() && (this.positionOnFadeComplete = false);
this._fireEvent('onOpenComplete');
}
}
}.bind(this);
Expand Down

0 comments on commit e4bd887

Please sign in to comment.