I'm currently developing a jQuery mobile app that requires filtering posts on a specific page. I have already added the posts and designed the filter.
Take a look at how it appears below:
https://i.sstatic.net/mVh9X.png
I am working on animating the filter so that when the user selects "social" on the right, "outside" and "business" will slide out to the left, keeping the selected filter in the center between the two dividers.
Here's an example of the JavaScript code I was planning to use to move the divs around, but for just 1 div instead of 3:
$(function(){
var c=0;
$("#click").click(function(){
$(this).stop().animate({left: ++c%2*100 }, 'fast');
});
});
The issue I encountered is that if the user keeps pressing the button on the right or left repeatedly, it would require an infinite number of divs sliding in. I am seeking advice on how to implement this more effectively.
Here's a JSFiddle with the assets I am using (minus the jQuery mobile styling): https://jsfiddle.net/xczy346z/
EDIT: Additionally, here is a GIF demonstrating the desired animation in case there are any difficulties understanding what I am trying to achieve: Example Gif