Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy or 'push' function #68

Closed
stokesbga opened this issue Jan 6, 2016 · 12 comments
Closed

Destroy or 'push' function #68

stokesbga opened this issue Jan 6, 2016 · 12 comments
Labels

Comments

@stokesbga
Copy link

I am having the same issue here:
#32

I want a dynamic flipster instance, and it would be nice to have 'add/remove' functions that allow me to populate flipster as needed. The 'destroy' function was never merged.

@shshaw
Copy link
Collaborator

shshaw commented Jan 7, 2016

In the public methods is an index function that will allow Flipster to update after you add or remove items like in this simple index demo

var flipContainer = $('.flipster'),
    flipItemContainer = flipContainer.find('.flip-items');

flipContainer.flipster({
  itemContainer: flipItemContainer,
  itemSelector: 'li',
  loop: true,
  style: 'carousel',
  spacing: -0.5,
  scrollwheel: false,
  //nav: 'after',
  buttons: false
});

flipItemContainer.children().eq(3).remove(); // Remove the fourth item (zero based index)
flipItemContainer.append("<li style='background: red; padding: 4em 1em;'>Hi! I'm a new Item!</li>"); // Add another item at the end.

flipContainer.flipster('index'); // Reindex items

Are you expecting some other functionality with add/remove? Would you need the destroy function regardless?

@stokesbga stokesbga reopened this Jan 8, 2016
@stokesbga
Copy link
Author

SMALL thing - when I call index after adding an element and navigate to it for the FIRST time - whether it be clicking, arrows, or flipster('jump', n), there is no transition animation. Is there any workaround for this that you know of ?

@shshaw
Copy link
Collaborator

shshaw commented Jan 8, 2016

Hm... I suspect a class is missing for some reason on the new item when index is run. How many items are you dealing with and where is the item you're adding? (Beginning, end, etc)

@stokesbga
Copy link
Author

I want one function to create elements called addFlipsterItem, which will append a list item to the ul. Initially, addFlipsterItem will be called n times to load default elements. From then, the user has the option to call addFlipsterItem manually. I am having the issue if i initialize flipster with no list elements, or if i have 1 initial element or 10.

@stokesbga
Copy link
Author

I fixed the animation jitter with:

function noTransition() {
                self.css('transition', 'none');
                //_container.css('transition', 'none');   // --> I commented this out and the spacing/ animation were back to normal. weird. 
                _items.css('transition', 'none');
            }

@shshaw
Copy link
Collaborator

shshaw commented Jan 11, 2016

Odd... The noTransition function shouldn't be called when index is run, though it is called during a resize event. I'm not sure exactly why that would have any effect. Something to dig into further.

As for an addFlipsterItem, I don't know that it would be all that useful compared to fixing the index bugs so that users can add or remove items from wherever in the flow.

Could you create a demo of how exactly you're adding items dynamically so I can better understand the use case for all of this?

@shshaw shshaw added the bug label Jan 11, 2016
@shshaw
Copy link
Collaborator

shshaw commented Jan 18, 2016

Very strange. Updated my Codepen demo to remove one item instead of adding, and it's working as expected. I'd love to see a demo of the behavior you're seeing.

@jagrutkosti
Copy link

I am facing the same problem as @stokesbga

@shshaw
Copy link
Collaborator

shshaw commented Feb 5, 2016

@jagrutkosti With the animation jitter or just adding items to a flipster instance?

@jagrutkosti
Copy link

With the animation jitter. Items are added successfully. I tried the solution mentioned by stokesbga but still it did not work for me.

@LoganLehman
Copy link

LoganLehman commented Aug 15, 2017

I am still running into this, has this been addressed yet @stokesbga @shshaw @drien?

@shshaw
Copy link
Collaborator

shshaw commented Aug 15, 2017

This issue has varied quite a bit from the initial request. Please provide a demo (You can fork this Codepen) of the behavior you're experiencing so it can be properly debugged and create a new issue.

I know there's probably quite a bit off in the library about the indexing when trying to add / remove items, but removing items should work correctly.

@shshaw shshaw closed this as completed Aug 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants