Code Monkey home page Code Monkey logo

Comments (18)

andrewyan avatar andrewyan commented on August 10, 2024 3

Hi David & Luis, thanks so much for your detail info. I'll check them out and probably need to learn a lot more about Angular :) You people are very helpful and I really appreciate that!

from ngx-scanner.

werthdavid avatar werthdavid commented on August 10, 2024 2

Have a look at this demo
As you can see I made an scss-file that contains a css-class that resizes the video to the desired size. Be aware that /deep/ is used in the example due to angulars view encapsulation
an alternative would be to set ViewEncapsulation.None inside the app-component.
Or to make it short: when you use /deep/ the style of that css-class is valid not only inside your component but through the whole angular-app

Hint: you can resize the video element via CSS, it won't change the aspect of the video itself though! That means that if your camera has e.g. a format of 4:3 and you change the size of the element via CSS to 16:9, the element is in fact resized to that size but the video itself will stay in 4:3 format giving you a (white) border

If you have any questions don't hesitate to ask

from ngx-scanner.

JanKe0909 avatar JanKe0909 commented on August 10, 2024 2

Hey guys, thank you for your help and your fast response. It works for me. 👍 Best regards, Jan

from ngx-scanner.

werthdavid avatar werthdavid commented on August 10, 2024 1

I'm fine with removing the attribute @odahcam but that's a breaking change so let's schedule that for an 2.x release.
I'd say performance is not a big issue so it's not that urgent..

from ngx-scanner.

werthdavid avatar werthdavid commented on August 10, 2024 1

I'll leave the issue open until we updated the Readme accordingly

from ngx-scanner.

odahcam avatar odahcam commented on August 10, 2024

Please change the size of the zxing-scanner element, the elements inside the component should not be entirely customizable to avoid some extra issues, so we bounded the preview-video size to the zxing-scanner element size.

We will update the docs ASAP to avoid this to happen again.

from ngx-scanner.

andrewyan avatar andrewyan commented on August 10, 2024

Hi, I’m a newbie to all these. I guess I’ve the same problem where the preview videos are always larger than the phone screen. Can someone put a simple example here how it can be shrinked to fit the screen? Many thanks!

from ngx-scanner.

odahcam avatar odahcam commented on August 10, 2024

You will loose the video proportions and the quality if you shrink the video. You can change the preview element size via CSS, there's only some existing styles you'll gotta overide. It just shouldn't be that way, but you can do that with some extra effort. Just do what @JanKe0909 did and add the required CSS overides so your styles are aplied to the element.

from ngx-scanner.

andrewyan avatar andrewyan commented on August 10, 2024

I'm really sorry. When I said I'm a newbie, I'm serious. Could you give me an example of these overrides?

from ngx-scanner.

odahcam avatar odahcam commented on August 10, 2024

As long as /deep/ is deprecated, I would like to suggest a change:

zxing-scanner::ng-deep video {
    /* ... */
}

In Angular you can use the ::ng-deep filter instead. 😁

Working example:
https://stackblitz.com/edit/zxing-ngx-scanner-layout-shvqdr?file=app%2Fapp.component.scss

Also, now that we have this built in feature, I would like to ask if it isn't time to remove the cssClass attribute. It could increase a little performance and maintainability, also docs about this could help new guys to find easier answers. What you think David? Maybe a new issue for discussion?

from ngx-scanner.

csutorasr avatar csutorasr commented on August 10, 2024

This could be achieved through an ngTemplate as ::ng-deep is not a solution.

from ngx-scanner.

odahcam avatar odahcam commented on August 10, 2024

None of them is a solution, ::ng-deep is just a lighter hack. Can you talk more about ngTemplate?

from ngx-scanner.

csutorasr avatar csutorasr commented on August 10, 2024

Here is the solution.

The video element and the template should be a ref. This way you can still control the video element, but with the template a css from the component is applied to the video element without ngDeep.

from ngx-scanner.

odahcam avatar odahcam commented on August 10, 2024

Yeah, this is a clean solution, but can be difficult for newbies (to use or implement).

This is not something meant to be changed, so I'm starting to think about sizing @Inputs such as width, height, proportions, etc.

The focus is to customize the zxing-scanner and maybe some new properties could solve the video size.

from ngx-scanner.

csutorasr avatar csutorasr commented on August 10, 2024

This one could solve all the problems. What about showing the current way, and add the Input properties; or you can choose to add a template, that can work the way I posted. A simple *ngIf="!templateRef; else templateRef" could work on video container element.

from ngx-scanner.

odahcam avatar odahcam commented on August 10, 2024

In that case, I prefer to create some zxing-scanner-directive you can put in a <video> tag than creating this kinda stuff, the directive is gonna easier to handle by both sides.

from ngx-scanner.

odahcam avatar odahcam commented on August 10, 2024

Closing as dicussion is now part of #83.

from ngx-scanner.

lock avatar lock commented on August 10, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from ngx-scanner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.