add split annotation feature
This commit is contained in:
parent
839decd4e6
commit
27cc1a81fd
2 changed files with 29 additions and 1 deletions
|
@ -257,6 +257,9 @@ async function loadClips(annotations) {
|
||||||
|
|
||||||
annotations.forEach(annotation => {
|
annotations.forEach(annotation => {
|
||||||
var clipId = annotation.clipId || annotation.id.split('/')[0] + '/' + annotation.in.toFixed(3) + '-'+ annotation.out.toFixed(3)
|
var clipId = annotation.clipId || annotation.id.split('/')[0] + '/' + annotation.in.toFixed(3) + '-'+ annotation.out.toFixed(3)
|
||||||
|
if (annotation.colorId && !colors[clipId]) {
|
||||||
|
colors[clipId] = colors[annotation.colorId]
|
||||||
|
}
|
||||||
if (!colors[clipId]) {
|
if (!colors[clipId]) {
|
||||||
console.log('no match for clip', clipId)
|
console.log('no match for clip', clipId)
|
||||||
return
|
return
|
||||||
|
@ -319,8 +322,31 @@ async function loadAnnotations(config) {
|
||||||
response.data.layers[layer] && response.data.layers[layer].forEach(annotation => {
|
response.data.layers[layer] && response.data.layers[layer].forEach(annotation => {
|
||||||
annotation.clipId = annotation.id.split('/')[0] + '/' + annotation.in.toFixed(3) + '-'+ annotation.out.toFixed(3)
|
annotation.clipId = annotation.id.split('/')[0] + '/' + annotation.in.toFixed(3) + '-'+ annotation.out.toFixed(3)
|
||||||
if (!(config.user && annotation.user != config.user) && isInside(config, annotation)) {
|
if (!(config.user && annotation.user != config.user) && isInside(config, annotation)) {
|
||||||
|
if (config.split && config.split.indexOf(layer) > -1) {
|
||||||
|
var parts = annotation.value.replace(/<br\ \/>/g, '<br>').replace(/<br\/>/g, '<br>').split('<br>')
|
||||||
|
var duration = (annotation.out - annotation['in']) / parts.length
|
||||||
|
if (parts.length > 1 && duration > 2) {
|
||||||
|
var position = annotation['in']
|
||||||
|
var part
|
||||||
|
while (parts.length) {
|
||||||
|
part = { ...annotation }
|
||||||
|
part['in'] = position
|
||||||
|
part['out'] = position + duration
|
||||||
|
part.clipId = part.id.split('/')[0] + '/' + part.in.toFixed(3) + '-'+ part.out.toFixed(3)
|
||||||
|
part.colorId = annotation.clipId
|
||||||
|
part.value = parts.pop(0)
|
||||||
|
if (parts.length) {
|
||||||
|
position = part['out']
|
||||||
|
} else {
|
||||||
|
position = annotation.out
|
||||||
|
}
|
||||||
|
annotations.push(part)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
annotations.push(annotation)
|
annotations.push(annotation)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return loadClips(annotations).then(annotations => {
|
return loadClips(annotations).then(annotations => {
|
||||||
|
|
|
@ -76,6 +76,8 @@ class PandoraScroll extends HTMLElement {
|
||||||
}
|
}
|
||||||
if (a.name == 'layers') {
|
if (a.name == 'layers') {
|
||||||
config[a.name] = a.value.split(' ')
|
config[a.name] = a.value.split(' ')
|
||||||
|
} else if (a.name == 'split') {
|
||||||
|
config[a.name] = a.value.split(' ')
|
||||||
} else if (['in', 'out'].indexOf(a.name) > -1) {
|
} else if (['in', 'out'].indexOf(a.name) > -1) {
|
||||||
config[a.name] = parseTime(a.value)
|
config[a.name] = parseTime(a.value)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue