micku7zu/vanilla-tilt.js

The compatibility of Pjax and vanilla-tilt.js

huangwb8 opened this issue · 2 comments

I'am a WordPress bloger (https://blognas.hwb0307.com) using both Pjax and vainlla-tilt.js. However, if I open Pjax, vanilaa-tilt.js would not work well unless I renew the home page. Is it possible to support Pjax when vanilla-tilt.js is used?

Hi, vanilla-tilt.js and Pjax has no conflicts and they work together.

Including the vanilla-tilt.js script on the end of your page body <script type="text/javascript" src="vanilla-tilt.js"></script> will apply the tilt effect only to the current elements that are on the page.

Be sure to call VanillaTilt.init(document.querySelectorAll("[data-tilt]")); on the new vanilla-tilt elements when the page changes with ajax.

It's not in the responsability of vanilla-tilt.js to detect element changes on the page, the developer should do that.

@micku7zu Thank you very much!