gijsroge / tilt.js

A tiny 60+fps parallax tilt hover effect for jQuery.

Home Page:http://gijsroge.github.io/tilt.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Script stops working after an ajax call / reloading items

AntonShumin opened this issue · comments

I am using an ajax call to reload the items that use tilt. (filtering and ordering by location for example).
The script removes all current items and generates new code, without reloading the page.
That causes tilt to stop working for the new items.

As a workaround i now send the vanilla tilt script with each ajax call, but it feels dirty.
I believe these can be solved by converting to delegate methods like .on("click".. instead of click(..)

image

Hi @AntonShumin

Thats because the elements are new and net yet binded to tilt.js. Just call .tilt() on those new elements. e.g. $('.ajax-wrapper .js-tilt').tilt(); the .ajax-wrapper has to be a wrapper element that is not replaced after the ajax call.