chessboardjsx icon indicating copy to clipboard operation
chessboardjsx copied to clipboard

using calcwidth

Open moblizeit opened this issue 4 years ago • 6 comments

i am using react and it says use calcWidth for responsive board. but how exactly?

what should i replace width={400} with? width={calcWidth} does not work

moblizeit avatar Feb 05 '21 04:02 moblizeit

Use the calcWidth prop instead of the width prop

willb335 avatar Feb 06 '21 17:02 willb335

example to do that? i am using it in a react native app and not sure what should be the value for this property

moblizeit avatar Feb 08 '21 06:02 moblizeit

@moblizeit

Remove your width propety and use calcWidth. calcWidth is a property like width, but instead of taking in a number, it takes in a function that returns a number (the dynamically-generated width). Here's an example:

calcWidth={(size) =>
            size.screenWidth > maxWidth &&
            size.screenHeight > maxWidth
              ? maxWidth
              : Math.min(size.screenWidth, size.screenHeight)
          }

The input parameter is size (which comes with screenWidth and screenHeight) and the output parameter is the width; in this case, it's the smaller of screenWidth or screenHeight below maxWidth.

jeremywiedemeier avatar Feb 15 '21 17:02 jeremywiedemeier

Hi @willb335 @jeremywiedemeier @moblizeit Any working react native example for chessboardjsx ? Is it good to use this library in react native ?

agam-colaburate avatar Apr 13 '21 18:04 agam-colaburate

@agam-colaburate

Not sure this can work within a webview for react native. Sorry no mobile examples

willb335 avatar Apr 15 '21 15:04 willb335

I guess Webview wont be a good option because we won't have any control over it, Thanks for replying though !

singhagam1 avatar Apr 15 '21 15:04 singhagam1