add showInToOut option to SmallVideoTimeline

This commit is contained in:
rolux 2013-02-15 10:49:33 +05:30
parent 4bdae7eb1e
commit 57ca8e44b4

View file

@ -14,7 +14,7 @@ Ox.SmallVideoTimeline = function(options, self) {
.defaults({ .defaults({
// _offset is a hack for cases where all these position: absolute // _offset is a hack for cases where all these position: absolute
// elements have to go into a float: left // elements have to go into a float: left
// FIXME: possible unused and unneeded // FIXME: possibly unused and unneeded
_offset: 0, _offset: 0,
disabled: false, disabled: false,
duration: 0, duration: 0,
@ -26,6 +26,7 @@ Ox.SmallVideoTimeline = function(options, self) {
out: 0, out: 0,
paused: false, paused: false,
results: [], results: [],
showInToOut: false,
showMilliseconds: 0, showMilliseconds: 0,
state: 'default', state: 'default',
subtitles: [], subtitles: [],
@ -143,12 +144,24 @@ Ox.SmallVideoTimeline = function(options, self) {
}); });
} }
function getLeft() {
return (
self.options.showInToOut
? self.options.position - self.options['in']
: self.options.position
) * self.imageWidth / self.options.duration;
}
function getPosition(e) { function getPosition(e) {
var position = ( var position = (
(e.offsetX ? e.offsetX : e.clientX - $(e.target).offset().left) (e.offsetX ? e.offsetX : e.clientX - $(e.target).offset().left)
- (self.options.mode == 'player' ? 8 : 0) - (self.options.mode == 'player' ? 8 : 0)
) * self.options.duration / self.imageWidth; ) * self.options.duration / self.imageWidth;
return Ox.limit(position, 0, self.options.duration); position = Ox.limit(position, 0, self.options.duration);
if (self.options.showInToOut) {
position += self.options['in'];
}
return position;
} }
function getSubtitle(position) { function getSubtitle(position) {
@ -171,6 +184,7 @@ Ox.SmallVideoTimeline = function(options, self) {
mode: self.options.mode, mode: self.options.mode,
out: self.options.out, out: self.options.out,
results: self.options.results, results: self.options.results,
showInToOut: self.options.showInToOut,
subtitles: self.options.subtitles, subtitles: self.options.subtitles,
state: self.options.state, state: self.options.state,
type: self.options.type, type: self.options.type,
@ -215,17 +229,15 @@ Ox.SmallVideoTimeline = function(options, self) {
function setPointMarker(point) { function setPointMarker(point) {
self.$pointMarker[point].css({ self.$pointMarker[point].css({
left: self.imageLeft + Math.round( left: self.imageLeft + Math.round(getLeft()) + 'px'
self.options[point] * self.imageWidth / self.options.duration
) + 'px'
}); });
} }
function setPositionMarker() { function setPositionMarker() {
self.$positionMarker.css({ self.$positionMarker.css({
left: self.interfaceLeft + Math.round( left: self.interfaceLeft + Math.round(getLeft())
self.options.position * self.imageWidth / self.options.duration - (self.options.mode == 'editor' ? 5 : 0)
) - (self.options.mode == 'editor' ? 5 : 0) + self.options._offset + 'px' + self.options._offset + 'px'
}); });
} }