Click Through w/o Image Map - Enhancement Idea
Closed this issue · 3 comments
marketinview commented
It would be nice to have an option to turn on click through without using an image map. I was able to do it myself with an afterLoad function, but it would have been useful to have an a clickThrough option that could be set to true.
thdoan commented
You can add this via afterLoad
event as you have done. Not enough people have asked for this, so I will not implement this for now.
jpmaradiaga commented
Sorry to necro this issue but I'm in need of something similar. Can anyone share and example?
marketinview commented
Sorry to necro this issue but I'm in need of something similar. Can anyone share and example?
I thought this feature was eventually added, but I might be imagining that.
Anyway, the following works:
var img = jQuery('img');
img.magnify({
src: img.attr("src"),
afterLoad: function() {
var lens = hmi.parent(".magnify").children(".magnify-lens");
lens.click(function(e) {
if (e.clientX || e.clientY) {
lens.hide();
clickxy(e.clientX, e.clientY);
}
});
}
});
function clickxy(x, y) {
var ev = new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': true,
'clientX': x,
'clientY': y
});
var el = document.elementFromPoint(x, y);
el.dispatchEvent(ev);
}