Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Option to mirror displayed video #769

Closed
paulharris opened this issue May 18, 2023 · 4 comments
Closed

[Feature Request] Option to mirror displayed video #769

paulharris opened this issue May 18, 2023 · 4 comments

Comments

@paulharris
Copy link

It is very hard for people to center their QR code in the camera when the video is not mirrored.
My phone and PC both don't mirror the front camera.
Is it possible to add a "mirror video" option?

@fabiochelly
Copy link

fabiochelly commented May 25, 2023

Personnaly, I detect if I'm on a mobile or desktop (through the user-agent), and I add a class "flip" to my container if not mobile:

CSS:

#qr-reader.flip video {
    transform: scaleX(-1);
}

Javascript:

const ismobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
const cls = ismobile ? '' : 'flip';
const size = ismobile ? 150 : 250;
mypanel.insertAdjacentHTML("afterbegin", `<div id="qr-reader" class="${cls}"></div>`);

It's not perfect but it works so far. the ideal would be to be able to detect if the camera is front (needs mirror) or back.

@paulharris
Copy link
Author

This is genius, thanks!
Even if I'm using mobile, I want to use the front camera, so the video should always be flipped anyway.

I noticed the flip will also apply to "Start Scanning" button, which is confusing.
So I applied it to just the __scan_region, ie:

#scanner_div__scan_region {
   transform: scaleX(-1);
}

Works great, thanks!

@MattPedrosa
Copy link

MattPedrosa commented Jul 17, 2023

@paulharris Sir, good evening. Can I ask an example of how you were able to fix your issue? Is there a way to implement this on REACT?

@paulharris
Copy link
Author

I used the CSS as above, where I had a <div style='width: 250px' id='scanner_div' class='scanner_div'>
but I don't think I needed the class in that div.
I don't use react so I can't say anything about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants