Skip to content

Commit

Permalink
Fix tests for new mouse over flag
Browse files Browse the repository at this point in the history
  • Loading branch information
i-like-robots committed Jun 16, 2014
1 parent d00a466 commit 855f064
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/easyzoom.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/easyzoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
* @param {Object} options
*/
function EasyZoom(target, options) {

this.$target = $(target);
this.opts = $.extend({}, defaults, options);
this.mouseOver = false;

if ( this.isOpen === undefined ) {
this._init();
Expand All @@ -57,7 +55,8 @@

this.$target
.on('mouseenter.easyzoom touchstart.easyzoom', function(e) {
self.mouseOver = true;
self.isMouseOver = true;

if ( ! e.originalEvent.touches || e.originalEvent.touches.length === 1) {
e.preventDefault();
self.show(e);
Expand All @@ -70,7 +69,8 @@
}
})
.on('mouseleave.easyzoom touchend.easyzoom', function() {
self.mouseOver = false;
self.isMouseOver = false;

if (self.isOpen) {
self.hide();
}
Expand All @@ -93,7 +93,7 @@

if (! this.isReady) {
this._load(this.$link.attr('href'), function() {
if (self.mouseOver) {
if (self.isMouseOver) {
self.show(e);
}
});
Expand Down
13 changes: 11 additions & 2 deletions test/spec/easyzoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

equal($.isEmptyObject(events), false, "Mouse and touch events bound to target");


});

test("API", function() {
Expand All @@ -50,6 +49,8 @@
start();
};

api.isMouseOver = true;

api.show();

});
Expand All @@ -74,6 +75,8 @@
start();
});

api.isMouseOver = true;

api.show(mock);

});
Expand All @@ -94,6 +97,8 @@
start();
};

api.isMouseOver = true;

api.show();

});
Expand All @@ -118,6 +123,8 @@
start();
};

api.isMouseOver = true;

api.show();

});
Expand Down Expand Up @@ -226,8 +233,10 @@
start();
};

api.isMouseOver = true;

api.show();

});

})();
})();

0 comments on commit 855f064

Please sign in to comment.