From e6e2e0e1d8455868ce1d19a19f49fe9e80fde25c Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Sun, 4 Sep 2011 21:36:41 +0000 Subject: [PATCH] add drag-to-scrub to video --- source/Ox.UI/js/Video/Ox.VideoPlayer.js | 29 ++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/source/Ox.UI/js/Video/Ox.VideoPlayer.js b/source/Ox.UI/js/Video/Ox.VideoPlayer.js index 7db4a0f8..3fd1cc78 100644 --- a/source/Ox.UI/js/Video/Ox.VideoPlayer.js +++ b/source/Ox.UI/js/Video/Ox.VideoPlayer.js @@ -269,8 +269,10 @@ Ox.VideoPlayer = function(options, self) { if (!$(e.target).is('.OxLogo')) { togglePaused(); } - } - // fixme: support drag (left-right) + }, + dragstart: dragstart, + drag: drag, + dragend: dragend }); self.$video = Ox.VideoElement( @@ -998,10 +1000,27 @@ Ox.VideoPlayer = function(options, self) { self.interfaceTimeout = 0; } - function ended() { - if (!self.options.paused) { - togglePaused(); + function dragstart() { + self.drag = { + position: self.options.position, + paused: self.options.paused } + !self.options.paused && togglePaused(); + } + + function drag(e) { + setPosition(self.drag.position - e.clientDX / 25); + that.triggerEvent('position', { + position: self.options.position + }); + } + + function dragend() { + !self.drag.paused && togglePaused(); + } + + function ended() { + !self.options.paused && togglePaused(); if (self.options.poster) { self.$poster.animate({ opacity: 1