Skip to content
This repository has been archived by the owner on May 27, 2021. It is now read-only.

Dynamically added cards don't "restack" #53

Open
m10l opened this issue Feb 16, 2015 · 9 comments
Open

Dynamically added cards don't "restack" #53

m10l opened this issue Feb 16, 2015 · 9 comments

Comments

@m10l
Copy link

m10l commented Feb 16, 2015

On load (and using ng-if) the cards I load in appear as a neat stack, however when I swipe a card out and a replacement is added from my API, the card doesn't appear in the correct place. Is there something I need to call?

I've created a codepen to illustrate the issue - http://codepen.io/anon/pen/ByYJmz

@moQuez
Copy link

moQuez commented Feb 28, 2015

Same here, been looking around but so far I really don't now what to call or to refresh

@beauby
Copy link
Contributor

beauby commented Mar 24, 2015

+1

@albertoalcaraz
Copy link

The same here. I've tried several ways of adding the cards but they always end up with bad stacking position (exactly as in the codepen).

Any news on this?

@sagivf
Copy link

sagivf commented Apr 11, 2015

Same here, this is really frustrating. No feature is better then a broken one (or one missing basic functionality).

@kayzee
Copy link

kayzee commented Apr 14, 2015

I assume the "unshift" isn't giving you expected results? I tried using unshift and it seems to work for me.

cards = ['1', '2', '3'];
cards.splice(0, 1);  // cards = ['2', '3']
cards.unshift(angular.extend({}, '4'));  // cards = ['4', '2', '3'], however the Tinder cards show up in the order ['2', '3', '4'], which is bizarre

@wireblue
Copy link

I found the currently visible card was typically the last in the array, so adding freshly loaded cards to the front (aka. array.unshift) fixed it for me.

@wbowlin
Copy link

wbowlin commented Jun 17, 2015

The issue is that the card zorder is set via sortCards which runs once after the ng-repeat first renders. One way to get around it is to just set the zorder yourself for each card via an inline style. You can see an example here: http://codepen.io/beoutside/pen/yNoWrR

@wbowlin
Copy link

wbowlin commented Jun 18, 2015

Here's a fork of the original pen with the z-order styling applied. It also changes addCard to add cards to the end of the array instead of the beginning since the first card is shown at the top of the stack. Now you can see a new card come into view at the bottom of the stack.

http://codepen.io/beoutside/pen/qdPZvW

@elhamsarikhani
Copy link

have you tried this:
$scope.cards.push(angular.extend({}, newCard));

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants