• Hi everyone,

    I was wondering if there is a propper/native way to handle decimals for the focal point picker component ?

    I’am building a simple gutenberg block, requiring precise positionning, with decimals (ex 88.5%) . I could surely handle this with custom fields, but I’m curious to know it if there would be a native way to handle this scenario

    <FocalPointPicker
       url={coverUrl ?? null}
       value={objectPosition}
       onChange={(focalPoint) => {
       handleChangeobjectPosition(focalPoint);
       }}
       resolvePoint={resolvepoint}
     />

    I’ve tried using the resolvePoint method mentionned in the doc, which outputs a precise position, but the number with decimals then get rounded when passed to the handleChange function anyway.



    Many thanks in advance for the Help,

Viewing 1 replies (of 1 total)
  • mdshak

    (@mdshak)

    I would suggest to manipulate the values of focal point before handleChangeobjectPositionfunction like this way.

    <FocalPointPicker
       url={coverUrl ?? null}
       value={objectPosition}
       onChange={(focalPoint) => {
       const newX = parseFloat(focalPoint.x.toFixed(2));
       const newY = parseFloat(focalPoint.y.toFixed(2));
       handleChangeobjectPosition(newX,newY);
       }}
       resolvePoint={resolvepoint}
     />
Viewing 1 replies (of 1 total)
  • The topic ‘handle Decimals with FocalPointPicker ?’ is closed to new replies.