micku7zu/vanilla-tilt.js

QuerySelectorAll makes the vanillaTilt.destroy function undefined

Z2r-YT opened this issue · 1 comments

since this script doesnt go well with safari, I have been attempting to make a script that destroys tilt on any object with a certain ID if the user is on safari, However, using document.querySelectorAll, makes vanillaTilt.destroy become undefined.
I'm not sure if this is a result of my bad scripting, or an issue in vanilla tilt itself. But any info would be useful.

my JS is as so:
`let destroyBox = document.querySelectorAll("#del");
VanillaTilt.init(destroyBox);

if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0)
{
VanillaTilt.init(destroyBox);
destroyBox.vanillaTilt.destroy();
alert("Browser is Safari");
}`

Well, I don't have Safari to replicate the issue, but I don't think the issue is in VanillaTilt.js.

Also, why would you initialize VanillaTilt for all browsers and then destroy for Safari, instead of initializing the VanillaTilt only for non safari browsers?

if(isNotSafari) {
  VanillaTilt.init(document.querySelectorAll("#tilt"));
}