update clip positions after sorting

This commit is contained in:
j 2014-02-06 15:14:02 +00:00
parent 53a3d37d74
commit ac9ed0f5a8

View file

@ -447,6 +447,7 @@ pandora.ui.editPanel = function() {
if (sort[0].operator == '-') { if (sort[0].operator == '-') {
edit.clips.reverse(); edit.clips.reverse();
} }
updateDuration();
callback(edit.clips); callback(edit.clips);
} else { } else {
pandora.api.sortClips({ pandora.api.sortClips({
@ -457,19 +458,24 @@ pandora.ui.editPanel = function() {
clip['sort'] = result.data.clips.indexOf(clip.id); clip['sort'] = result.data.clips.indexOf(clip.id);
}); });
edit.clips = Ox.sortBy(edit.clips, 'sort'); edit.clips = Ox.sortBy(edit.clips, 'sort');
updateDuration();
callback(edit.clips); callback(edit.clips);
}); });
} }
} }
function updateClips(clips) { function updateDuration() {
clips = clips || edit.clips;
edit.clips = clips;
edit.duration = 0; edit.duration = 0;
edit.clips.forEach(function(clip) { edit.clips.forEach(function(clip) {
clip.position = edit.duration; clip.position = edit.duration;
edit.duration += clip.duration; edit.duration += clip.duration;
}); });
}
function updateClips(clips) {
clips = clips || edit.clips;
edit.clips = clips;
updateDuration();
that.options({ that.options({
clips: Ox.clone(edit.clips), clips: Ox.clone(edit.clips),
duration: edit.duration, duration: edit.duration,