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
- Go to http://ali.dj/blog
- Click on one of the three playlist-images
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