I’m wanting to remove and add slides from a slidebox dynamically in order to prevent two many elements being created on the dom.
At the moment I have a list of a bunch of items. I want to represent this list as: prev-prev-item, prev-item, middle-item, next-item, next-next-item. I would start at middle item, on going next slide I want to remove prev-prev and add on a next-next-next, on going prev slide i want to remove next-next and add prev-prev-prev. However doing so seems to cause strange issues with disappearing slide content.
Here’s a brief demo with two slides: http://codepen.io/anon/pen/vhgBq
What happens here is I add a new slide and remove the first. The slidebox should never have a length longer than 2.