francoischalifour / medium-zoom

🔎🖼 A JavaScript library for zooming images like Medium
https://medium-zoom.francoischalifour.com
MIT License
3.62k stars 165 forks source link

Allow for disabling default setting #8

Closed E-VANCE closed 7 years ago

E-VANCE commented 7 years ago

Hi there,

am using your plugin on a site of mine and everything works fine so far (great suite!) but there is one issue / quetsion I am facing:

How can I (globally) set the plugin's setting to not select any images by default and only work with what I am providing?

By default, the zoom is applied to all scaled images (with HTML or CSS properties). You can specify the zoomable images with a CSS selector and add options.

Specyfing zoomable images only adds to the default selection, at least when I tried...

mediumZoom(document.querySelectorAll('[data-action="zoom"]'));

Thanks for any input on how to achieve this!

EDIT: Might be connected to #7 since it is triggering on my SVG? No tag as parent or anywhere near that SVG though...

<svg id="open-slash" data-name="open-slash" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 9.08 13.28" class="medium-zoom-image"><path class="slash" d="M148.58,282.81h-1.16l7.91-13.28h1.16Z" transform="translate(-147.41 -269.53)"></path></svg>

francoischalifour commented 7 years ago

Hi @E-VANCE, thanks for the feedback!

After investigating, you're totally right. The isArrayLike function, which is in charge of detecting NodeLists and HTML Collections is broken.

That's the reason why it falls back to SUPPORTED_FORMATS, which contains svgs.

I've fixed the issue but will spend more time thinking about any possible breaking changes. I'll publish the fix in the next days.

Thanks again 👍

francoischalifour commented 7 years ago

It should be fixed now. Please let me know if you find any other issues.