summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorccd0 <admin@containerchan.org>2013-11-13 23:17:09 -0800
committerccd0 <admin@containerchan.org>2013-11-13 23:17:09 -0800
commit6b0b1fe144d1bdc876c29edb827f172e82794176 (patch)
tree748cea8e483678465eb54d0fa1a890d9b7b4901d
parent7ddaa54be50565532976b69e93ce38de3904b157 (diff)
drag to right to collapse video
-rw-r--r--expandvideo.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/expandvideo.js b/expandvideo.js
index 7a68f631..ef21b62f 100644
--- a/expandvideo.js
+++ b/expandvideo.js
@@ -6,6 +6,7 @@ function setupVideo(thumb, url) {
var loop = true;
var loopControls = [document.createElement("span"), document.createElement("span")];
var fileInfo = thumb.parentNode.querySelector(".fileinfo");
+ var mouseDown = false;
function unexpand() {
if (expanded) {
@@ -54,6 +55,23 @@ function setupVideo(thumb, url) {
videoContainer.addEventListener("click", function(e) {
if (e.target != video) unexpand();
} , false);
+
+ // Dragging to the left collapses the video
+ video.addEventListener("mousedown", function(e) {
+ if (e.button == 0) mouseDown = true;
+ }, false);
+ video.addEventListener("mouseup", function(e) {
+ if (e.button == 0) mouseDown = false;
+ }, false);
+ video.addEventListener("mouseenter", function(e) {
+ mouseDown = false;
+ }, false);
+ video.addEventListener("mouseout", function(e) {
+ if (mouseDown && e.clientX - video.getBoundingClientRect().left <= 0) {
+ unexpand();
+ }
+ mouseDown = false;
+ }, false);
}
}