Replies: 1 comment
-
I suspect it may work to side-step the issue using const refPrecisePoint = useRef();
<FocalPointPicker
url={coverUrl ?? null}
value={objectPosition}
onChange={() => {
handleChangeobjectPosition(refPrecisePoint.current);
}}
resolvePoint={(focalPoint) => {
const [ x, y ] = Object.values( focalPoint ).map(
// Clamps the value from zero to one and rounds to three decimals.
v => Math.round( Math.max( 0, Math.min( v, 1 ) * 1e3 ) ) / 1e3
);
refPrecisePoint.current = { x, y };
return focalPoint;
}}
/> If that doesn’t work, it’s going to require opening a feature request that |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I'm reposting a question originally submitted here.
(with the idea here might be a better place for that kind of question ? ) .
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.
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,
Beta Was this translation helpful? Give feedback.
All reactions