protonet / jquery.inview

A jQuery plugin that adds a bindable 'inview' event for detecting when an element is scrolled into view.
blog.protonet.info/post/2516624585/jquery-inview-plugin
Do What The F*ck You Want To Public License
1.67k stars 488 forks source link

Does not fire for async elements in view #43

Open cssagogo opened 9 years ago

cssagogo commented 9 years ago

I'm working on a dashboard with modules that load when inview. The script works great until I change date ranges and clear out the contents of the modules. When this happens the elements inview on change do not load because they never left the view. They do not fire until I scroll down and back again. So how do I make inview see the items as new elements again?

Here is a bin of the issue I'm having. The items start yellow and then get changed to red. On click of reset the items are changed back to yellow, but because the inview already fired off the items do not respond. Anyway to get inview to behave as if on a fresh page load?

http://jsbin.com/lameya/4/edit

mhaagens commented 9 years ago

I also have trouble getting the plugin to fire on AJAX-loaded DOM elements.

peazz commented 8 years ago

me three

TheCleric commented 8 years ago

I also had this issue, but I discovered it's because of the scroll event. The scroll event fires on page load, but not after ajax events, so if you fire this event manually:

$(window).scroll();

after doing your ajax call and rebind of the event it will catch your new items.