|
|
@ -47,16 +47,20 @@ function createScanner(pixelCapturer) {
|
|
|
|
const source = pixelCapturer ? pixelCapturer.getSource() : {};
|
|
|
|
const source = pixelCapturer ? pixelCapturer.getSource() : {};
|
|
|
|
|
|
|
|
|
|
|
|
function updateViewportStyle(target) {
|
|
|
|
function updateViewportStyle(target) {
|
|
|
|
const $video = source.getDrawable();
|
|
|
|
const $drawable = source.getDrawable();
|
|
|
|
const $viewport = getViewport(target);
|
|
|
|
const $viewport = getViewport(target);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!$viewport) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const {viewport} = source.getDimensions();
|
|
|
|
const {viewport} = source.getDimensions();
|
|
|
|
const zoom = Math.floor((((2 * viewport.x) + viewport.width) / viewport.width) * 100) / 100;
|
|
|
|
const zoom = Math.floor((((2 * viewport.x) + viewport.width) / viewport.width) * 100) / 100;
|
|
|
|
const videoWidth = zoom * viewport.width;
|
|
|
|
const videoWidth = zoom * viewport.width;
|
|
|
|
const translate = ((viewport.x / videoWidth) * (-100)).toFixed(5);
|
|
|
|
const translate = ((viewport.x / videoWidth) * (-100)).toFixed(5);
|
|
|
|
|
|
|
|
|
|
|
|
$video.style.width = `${zoom * 100}%`;
|
|
|
|
$drawable.style.width = `${zoom * 100}%`;
|
|
|
|
$video.style.transform = `translate(${translate}%, ${translate}%)`;
|
|
|
|
$drawable.style.transform = `translate(${translate}%, ${translate}%)`;
|
|
|
|
$viewport.style.paddingBottom = `${(viewport.height * 100 / viewport.width).toFixed(5)}%`;
|
|
|
|
$viewport.style.paddingBottom = `${(viewport.height * 100 / viewport.width).toFixed(5)}%`;
|
|
|
|
$viewport.style.overflow = "hidden";
|
|
|
|
$viewport.style.overflow = "hidden";
|
|
|
|
$viewport.style.height = 0;
|
|
|
|
$viewport.style.height = 0;
|
|
|
|