image-focus icon indicating copy to clipboard operation
image-focus copied to clipboard

Support for <picture> element

Open brianjacobs-natgeo opened this issue 4 years ago • 1 comments

Hi, great library!

In using this I've wanted to use it for images within the <picture> element

Because image-focus looks for the parentElement of an image as the container, styling can get messed up if the parent is a <picture>. This line has worked as a fix for me, bypassing the parent <picture>

this.container = imageNode.parentElement.tagName == "PICTURE" ? imageNode.parentElement.parentElement : imageNode.parentElement;

Alternatively, allow me to explicitly set a container option that would override the default parentElement

brianjacobs-natgeo avatar Oct 12 '20 20:10 brianjacobs-natgeo

Hi @brianjacobs-natgeo, I proposed a change to the library that follows your proposed solution using options, see #50.

frsinn avatar Sep 12 '23 13:09 frsinn