|
53 | 53 | this.$flyout = $('<div class="easyzoom-flyout" />');
|
54 | 54 | this.$notice = $('<div class="easyzoom-notice" />');
|
55 | 55 |
|
56 |
| - this.$target |
57 |
| - .on('mousemove.easyzoom touchmove.easyzoom', $.proxy(this._onMove, this)) |
58 |
| - .on('mouseleave.easyzoom touchend.easyzoom', $.proxy(this._onLeave, this)) |
59 |
| - .on('mouseenter.easyzoom touchstart.easyzoom', $.proxy(this._onEnter, this)); |
| 56 | + this.$target.on({ |
| 57 | + 'mousemove.easyzoom touchmove.easyzoom': $.proxy(this._onMove, this), |
| 58 | + 'mouseleave.easyzoom touchend.easyzoom': $.proxy(this._onLeave, this), |
| 59 | + 'mouseenter.easyzoom touchstart.easyzoom': $.proxy(this._onEnter, this) |
| 60 | + }); |
60 | 61 |
|
61 |
| - this.opts.preventClicks &&this.$target.on('click.easyzoom', function(e) { |
| 62 | + this.opts.preventClicks && this.$target.on('click.easyzoom', function(e) { |
62 | 63 | e.preventDefault();
|
63 | 64 | });
|
64 | 65 | };
|
|
111 | 112 |
|
112 | 113 | this.isMouseOver = true;
|
113 | 114 |
|
114 |
| - if (touches && touches.length == 1) { |
| 115 | + if (!touches || touches.length == 1) { |
115 | 116 | e.preventDefault();
|
116 | 117 | this.show(e, true);
|
117 | 118 | }
|
|
132 | 133 | /**
|
133 | 134 | * On leave
|
134 | 135 | * @private
|
135 |
| - * @param {Event} e |
136 | 136 | */
|
137 |
| - EasyZoom.prototype._onLeave = function(e) { |
| 137 | + EasyZoom.prototype._onLeave = function() { |
138 | 138 | this.isMouseOver = false;
|
139 | 139 | this.isOpen && this.hide();
|
140 | 140 | };
|
|
180 | 180 | * @param {Function} callback
|
181 | 181 | */
|
182 | 182 | EasyZoom.prototype._loadImage = function(href, callback) {
|
183 |
| - var zoom = new Image(); |
| 183 | + var zoom = new Image; |
184 | 184 |
|
185 | 185 | this.$target
|
186 | 186 | .addClass('is-loading')
|
|
205 | 205 | var touchlist = e.touches || e.originalEvent.touches;
|
206 | 206 | lx = touchlist[0].pageX;
|
207 | 207 | ly = touchlist[0].pageY;
|
208 |
| - } |
209 |
| - else { |
| 208 | + } else { |
210 | 209 | lx = e.pageX || lx;
|
211 | 210 | ly = e.pageY || ly;
|
212 | 211 | }
|
|
220 | 219 | // Close if outside
|
221 | 220 | if (xl < 0 || xt < 0 || xl > dw || xt > dh) {
|
222 | 221 | this.hide();
|
223 |
| - } |
224 |
| - else { |
| 222 | + } else { |
225 | 223 | var top = xt * -1;
|
226 | 224 | var left = xl * -1;
|
227 | 225 |
|
|
300 | 298 |
|
301 | 299 | if (!api) {
|
302 | 300 | $.data(this, 'easyZoom', new EasyZoom(this, options));
|
303 |
| - } |
304 |
| - else if (api.isOpen === undefined) { |
| 301 | + } else if (api.isOpen === undefined) { |
305 | 302 | api._init();
|
306 | 303 | }
|
307 | 304 | });
|
|
312 | 309 | define(function() {
|
313 | 310 | return EasyZoom;
|
314 | 311 | });
|
315 |
| - } |
316 |
| - else if (typeof module !== 'undefined' && module.exports) { |
| 312 | + } else if (typeof module !== 'undefined' && module.exports) { |
317 | 313 | module.exports = EasyZoom;
|
318 | 314 | }
|
319 | 315 |
|
|
0 commit comments