Help please.Have an error in console
TypeError: Cannot read properties of undefined (reading ‘destroy’)
if (window.innerWidth > 991.98) {
VanillaTilt.init(destroyBox, {
max: 10,
speed: 10000
})
} else {
destroyBox.vanillaTilt.destroy();
}
>Solution :
You can’t destroy when never been init. That is the fix. However for an ugly workaround you can
if (window.innerWidth > 991.98) {
destroyBox.vanillaTilt || VanillaTilt.init(destroyBox, {
max: 10,
speed: 10000
})
} else {
destroyBox.vanillaTilt && destroyBox.vanillaTilt.destroy();
}