From 81dbba64e2c34b15186f30fbd76cf1cbd44038bc Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 9 Nov 2013 16:35:35 -0800 Subject: [PATCH] fix size computation for hover --- expandvideo.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/expandvideo.js b/expandvideo.js index 4ecddd60..8d6124b3 100644 --- a/expandvideo.js +++ b/expandvideo.js @@ -59,6 +59,7 @@ function setupVideo(thumb, url) { video.style.position = "static"; video.style.maxWidth = ""; video.style.maxHeight = ""; + video.style.pointerEvents = "auto"; video.style.display = "inline"; videoHide.style.display = "inline"; @@ -78,11 +79,19 @@ function setupVideo(thumb, url) { expanded = false; hovering = true; + var docRight = document.body.parentNode.getBoundingClientRect().right; + var thumbRight = thumb.querySelector("img, video").getBoundingClientRect().right; + var maxWidth = docRight - thumbRight - 20; + if (maxWidth < 250) maxWidth = 250; + video.style.position = "fixed"; video.style.right = "0px"; video.style.top = "0px"; - video.style.maxWidth = (document.body.parentNode.getBoundingClientRect().right - thumb.getBoundingClientRect().right) + "px"; + var docRight = document.body.parentNode.getBoundingClientRect().right; + var thumbRight = thumb.querySelector("img, video").getBoundingClientRect().right; + video.style.maxWidth = maxWidth + "px"; video.style.maxHeight = "100%"; + video.style.pointerEvents = "none"; video.style.display = "inline"; videoHide.style.display = "none";