forked from 0x2620/oxjs
update video editor
This commit is contained in:
parent
f5d587cf5b
commit
7da384d03a
5 changed files with 98 additions and 38 deletions
|
|
@ -42,6 +42,8 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
})
|
||||
.options(options || {});
|
||||
|
||||
self.points = getPoints();
|
||||
self.position = self.options.position;
|
||||
self.sort = getSort();
|
||||
self.widget = self.options.type == 'event' ? 'Calendar'
|
||||
: self.options.type == 'place' ? 'Map' : '';
|
||||
|
|
@ -143,6 +145,7 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
.bindEvent({
|
||||
// FIXME: should be select, not selectplace
|
||||
selectplace: function(data) {
|
||||
Ox.print('ANNOTATION ID IS', data.annotationId)
|
||||
self.$annotations.options({selected: data.annotationId});
|
||||
// selectAnnotation({id: data.annotationId});
|
||||
}
|
||||
|
|
@ -228,6 +231,15 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
that.triggerEvent('change', item);
|
||||
}
|
||||
|
||||
function crossesPoint() {
|
||||
var sort = [self.position, self.options.position].sort(),
|
||||
positionA = sort[0],
|
||||
positionB = sort[1];
|
||||
return self.points.some(function(point) {
|
||||
return point > positionA && point < positionB;
|
||||
});
|
||||
}
|
||||
|
||||
function dragstart() {
|
||||
if (self.options.showWidget) {
|
||||
self.drag = {
|
||||
|
|
@ -279,6 +291,14 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
function getPoints() {
|
||||
return Ox.unique(Ox.flatten(
|
||||
self.options.items.map(function(item) {
|
||||
return [item['in'], item.out];
|
||||
})
|
||||
));
|
||||
}
|
||||
|
||||
function getEvents() {
|
||||
var events = [];
|
||||
getAnnotations().forEach(function(item) {
|
||||
|
|
@ -388,7 +408,8 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
if (['in', 'out'].indexOf(key) > -1 && self.editing) {
|
||||
var index = Ox.getIndexById(self.options.items, self.options.selected);
|
||||
self.options.items[index][key] = value;
|
||||
self.options.items[index].duration = self.options.out - self.options['in'];
|
||||
self.options.items[index].duration = self.options.out - self.options['in'];
|
||||
self.points = getPoints();
|
||||
}
|
||||
if (key == 'in') {
|
||||
//fixme: array editable should support item updates while editing
|
||||
|
|
@ -403,9 +424,11 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
}
|
||||
} else if (key == 'position') {
|
||||
if (self.options.range == 'position') {
|
||||
Ox.print('POSITION CHANGED, UPDATING')
|
||||
self.widget && updateWidget();
|
||||
updateAnnotations();
|
||||
if (crossesPoint()) {
|
||||
self.widget && updateWidget();
|
||||
updateAnnotations();
|
||||
}
|
||||
self.position = self.options.position;
|
||||
}
|
||||
} else if (key == 'range') {
|
||||
self.widget && updateWidget();
|
||||
|
|
|
|||
|
|
@ -243,15 +243,33 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
}
|
||||
|
||||
function selectAnnotation(data, index) {
|
||||
var height, scrollTop;
|
||||
var height, scrollBottom, scrollTop, top;
|
||||
if (data.id) {
|
||||
self.$folder.forEach(function($folder, i) {
|
||||
i != index && $folder.options({selected: ''});
|
||||
});
|
||||
}
|
||||
if (data.top) {
|
||||
data.bottom = data.top + data.height;
|
||||
height = self.$folders.height();
|
||||
top = self.$folders.offset().top;
|
||||
Ox.print('top', top);
|
||||
scrollTop = self.$folders.scrollTop();
|
||||
Ox.print('data/self t/b/h', data.top, data.bottom, data.height, scrollTop, height)
|
||||
if (data.top < top || data.bottom > height) {
|
||||
if (data.top < top) {
|
||||
Ox.print('top scrollTop', data.top, scrollTop)
|
||||
scrollTop += data.top - top;
|
||||
} else {
|
||||
scrollTop += data.bottom - top - height;
|
||||
}
|
||||
self.$folders.animate({
|
||||
scrollTop: scrollTop + 'px'
|
||||
}, 0);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
data.top -= 60; // 20 + 24 + 16
|
||||
Ox.print('HEIGHT', height, 'SCROLLTOP', scrollTop, 'TOP', data.top);
|
||||
if (data.top < 0 || data.top > height - 16) {
|
||||
|
|
@ -260,10 +278,8 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
} else if (data.top > height - 16) {
|
||||
scrollTop += data.top - height + 14;
|
||||
}
|
||||
self.$folders.animate({
|
||||
scrollTop: scrollTop + 'px'
|
||||
}, 0);
|
||||
}
|
||||
*/
|
||||
}
|
||||
that.triggerEvent('select', data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue