Skip to content

Commit

Permalink
Merge pull request i-like-robots#87 from leoquijano/master
Browse files Browse the repository at this point in the history
Added beforeShow and beforeHide events (Issue i-like-robots#84)
  • Loading branch information
i-like-robots committed Mar 21, 2016
2 parents 14079e0 + e474793 commit 01f91b6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/easyzoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
// Prevent clicks on the zoom image link.
preventClicks: true,

// Callback function to execute before the flyout is displayed.
beforeShow: $.noop,

// Callback function to execute before the flyout is removed.
beforeHide: $.noop,

// Callback function to execute when the flyout is displayed.
onShow: $.noop,

Expand Down Expand Up @@ -73,6 +79,8 @@
var w1, h1, w2, h2;
var self = this;

if (this.opts.beforeShow.call(this) === false) return;

if (!this.isReady) {
return this._loadImage(this.$link.attr('href'), function() {
if (self.isMouseOver || !testMouseOver) {
Expand Down Expand Up @@ -238,6 +246,7 @@
*/
EasyZoom.prototype.hide = function() {
if (!this.isOpen) return;
if (this.opts.beforeHide.call(this) === false) return;

this.$flyout.detach();
this.isOpen = false;
Expand Down

0 comments on commit 01f91b6

Please sign in to comment.