I had a cropping plugin that allowed for panning of an image when you dragged on it. I wanted to apply a mask png over the top to give the impression of a cut shape. here is the jsfiddle
It uses the css3 property pointer-events:none;
on the image mask div, and it works in webkit browsers like chrome and firefox. But it doesn't work in IE because pointer-events: none;
only works on an SVG.
I did a lot of research in how to pass pointer events through divs. I tried some solutions, but they were a headache, and some didn't work:
forward mouse events through layers
After looking more into the plugin I was using I was able to extend it and get it to work in an IE browser (tested 8 and 9 only) and other browsers, not utilizing the pointer-events
option. Here is the jsfiddle of the new version. But I don't really know why it is working?? I basically did three things.
- Pass the mask src in as an option
Add a check to see if a mask option is provided, if so load the function:
if (this.options.mask_src) { var masksrc = this.options.mask_src; this.createMask(masksrc); }
Have the function append a div with mask image as the background image to the document div:
createMask: function(m_src) { $('<div class="iviewer_image_mask" style="background: url('+ m_src +');"></div>').appendTo(this.container); },
Can anyone explain to me why this solution works for image panning that has a mask layer overtop? It's like it is only applying mouse events to the image, and ignoring the mask layer.