Commit b9169dc5 by Jonathan Thomas

New drag and drop re-arranging for clips. Also adding a new FX button to clips - work in progress.

parent 5f49e014
...@@ -348,19 +348,30 @@ export default createStore({ ...@@ -348,19 +348,30 @@ export default createStore({
}, },
async moveClip({dispatch, getters}, payload) { async moveClip({dispatch, getters}, payload) {
let local_clips = [...getters.thumbnailedClips] let local_clips = [...getters.thumbnailedClips]
let reordered_clips = local_clips if (!Array.isArray(local_clips) || local_clips.length === 0) {
if (payload.current != payload.dest) { return
reordered_clips = reorderArray(local_clips, payload.current, payload.dest)
} }
if (payload.current === payload.dest || payload.current === undefined || payload.dest === undefined) {
return
}
let reordered_clips = reorderArray(local_clips, payload.current, payload.dest)
let pos = 0.0 let pos = 0.0
for (let c of reordered_clips) { let updates = []
c.position = pos const maxIndex = reordered_clips.length - 1
let edit_payload = { data: c, latest: false, thumbnail: false } const affectedStart = Math.max(0, Math.min(payload.current, payload.dest))
if (c.id == payload.clip.id) { const affectedEnd = Math.min(maxIndex, Math.max(payload.current, payload.dest))
edit_payload.latest = true for (let i = 0; i < reordered_clips.length; i++) {
let clip = reordered_clips[i]
let newPosition = pos
if (i >= affectedStart && i <= affectedEnd && clip.position !== newPosition) {
clip.position = newPosition
let edit_payload = { data: clip, latest: clip.id == payload.clip.id, thumbnail: false }
updates.push(edit_payload)
} }
pos += (clip.end - clip.start)
}
for (let edit_payload of updates) {
dispatch('editClip', edit_payload) dispatch('editClip', edit_payload)
pos += (c.end - c.start)
} }
}, },
async deleteClip({commit}, clip_id) { async deleteClip({commit}, clip_id) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment