Forums › Forums › Search & Filter Pro › Isotope animation
- This topic has 10 replies, 3 voices, and was last updated 5 years, 8 months ago by
Ross.
-
Trevor(Private) August 21, 2019 at 10:05 am #219416
Are you able to send me a live link/URL to your search page so I can take a look?
What animations are you trying to add, as it is normally used to remove space in columns resulting from unequal height sized posts?
How was your grid made (coded by you, plugin, theme template)?
Trevor(Private) August 21, 2019 at 4:33 pm #219457The only work we have done looking directly at Masonry/Isotope is contained here in this thread:
https://support.searchandfilter.com/forums/topic/reload-masonry-grid-after-ajax-call/
Otherwise we have looked mainly at how other themes have implemented it.
(any private posts in that thread are not relevant to this question)
Trevor(Private) August 22, 2019 at 8:39 am #219503We do have a jQuery action you can use to trigger anything JavaScript after or as our filter happens?
(function ( $ ) { "use strict"; //detects the start of an ajax request being made $(document).on("sf:ajaxstart", ".searchandfilter", function(){ console.log("ajax start"); //start your animation, if you need to at this point, otherwise don't use this start trigger }); //detects when the ajax request has finished and the content has been updated // - add scripts that apply to your results here $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); //do or stop your animation }); }(jQuery));
Anonymous(Private) October 23, 2019 at 9:59 am #224437Hi Trevor,
So I couldn’t get this to work and asked a more experienced developer to work on it, but he tells me that this function can’t be used to trigger css animations as the html gets replaced, and that using JS would require overriding the plugin and use JS to filter the data instead of Ajax.
I would really be interested in having your or Ross’ opinion on this.
Thanks,
Ross Moderator(Private) October 23, 2019 at 2:04 pm #224451Hi Thomas
Thanks for your enquiry, I’m going to break down my reply into two parts:
1) The animation here – cannot be done
The way this works is, isotope already knows all of the results / elements in advance.
When you use S&F, you only know the first (for example) 10 results, so you cannot animate the options in and out like this. Your developer is correct in that the existing results get removed, and the new ones loaded in, via a seperate request.
You’ll notice the isotope site doesn’t have an example of the animations, with filters, and an ajax request.
However, they do have a load more example, something which you might be able to implement if you have load more functionality in your search results:
https://isotope.metafizzy.co/v1/demos/infinite-scroll.html2) You are still able to use animations – just not the type you linked to (because all the results are preloaded). You can use the the events Trevor linked to stop / start animations when new results are being fetched, or when new results are loaded in.
My logic would be:
a) on the
sf:ajaxstart
start event (when new results are being requested), do any animation you wish to show the items dissapearing
b) on thesf:ajaxfinish
event – the results have been loaded, so you could set their state to invisible using JS, and then proceed to do whatever animation you like to have them appear on screen.You can use CSS animations, triggered by jquery (ie, by adding / removing a class that has animation properties) – https://stackoverflow.com/questions/9850856/activate-css-animation-by-jquery
I hope that helps!
Thanks
-
AuthorPosts