dimanche 22 mars 2015

Replacing item in bound array renders it briefly without it

I've got a playlist with artwork images. When I click on one the old current track is taking their place. Therefore I replace the item in the array.


When Ember re-renders the items for a very brief moment the replaced element disappears. This leads to an ugly effect where everything is re-positioned.


You can see the effect here



This is my simplified controller:



import Ember from 'ember';

export default Ember.ArrayController.extend({

playlist: null,
currentTrack: null;
actions: {
replaceItem: function(){
playlist.replace(index, 1, [self.get("currentTrack")])
}
}
}


This is the template:



{{#each song in playlist}}
<div class="song" {{action "changeTrack" song}}>
<img {{bind-attr src=song.artwork_url}} />
</div>
{{/each}}




Aucun commentaire:

Enregistrer un commentaire