Skip to content

Commit

Permalink
Added linkAttribute option, defaulting to 'href'
Browse files Browse the repository at this point in the history
The point is to take an zoom image URL from something other than <a
href="..."> allowing to use the href link for other purposes. The
default is 'href', so it should be backward compatible.

For issue i-like-robots#90
  • Loading branch information
amaltsev committed Apr 5, 2016
1 parent 01f91b6 commit 3cb15fd
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/easyzoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@
onHide: $.noop,

// Callback function to execute when the cursor is moved while over the image.
onMove: $.noop
onMove: $.noop,

// Link attribute to retrieve the zoom image URL from, normally 'href'.
// Can be set to, for instance, 'data-zoom-url' if href points
// to something other than the large image.
//
linkAttribute: 'href'

};

Expand Down Expand Up @@ -82,7 +88,7 @@
if (this.opts.beforeShow.call(this) === false) return;

if (!this.isReady) {
return this._loadImage(this.$link.attr('href'), function() {
return this._loadImage(this.$link.attr(this.opts.linkAttribute), function() {
if (self.isMouseOver || !testMouseOver) {
self.show(e);
}
Expand Down Expand Up @@ -275,7 +281,7 @@
srcset: $.isArray(srcset) ? srcset.join() : srcset
});

this.$link.attr('href', zoomHref);
this.$link.attr(this.opts.linkAttribute, zoomHref);
};

/**
Expand Down

0 comments on commit 3cb15fd

Please sign in to comment.