Skip to content

Commit 73d492b

Browse files
spescinai-like-robots
authored andcommitted
added onMove callback in options
1 parent 41394ce commit 73d492b

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

dist/easyzoom.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

+6
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ <h1>
240240
<dd>
241241
Callback function to execute when the flyout is removed. Default: <code>undefined</code>
242242
</dd>
243+
<dt>
244+
<var>onMove</var>
245+
</dt>
246+
<dd>
247+
Callback function to execute when the cursor is moved while over the image. Default: <code>undefined</code>
248+
</dd>
243249
</dl>
244250

245251
</section>

src/easyzoom.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
onShow: undefined,
2323

2424
// Callback function to execute when the flyout is removed.
25-
onHide: undefined
25+
onHide: undefined,
26+
27+
// Callback function to execute when the cursor is moved while over the image.
28+
onMove: undefined
2629

2730
};
2831

@@ -203,10 +206,17 @@
203206
this.hide();
204207
}
205208
else {
209+
var top = xt * -1;
210+
var left = xl * -1;
211+
206212
this.$zoom.css({
207-
top: '' + (xt * -1) + 'px',
208-
left: '' + (xl * -1) + 'px'
213+
top: top,
214+
left: left
209215
});
216+
217+
if (this.opts.onMove) {
218+
this.opts.onMove.call(this, top, left);
219+
}
210220
}
211221

212222
};

0 commit comments

Comments
 (0)