Skip to content

Commit

Permalink
fix #72
Browse files Browse the repository at this point in the history
  • Loading branch information
SrBrahma committed May 10, 2023
1 parent 23a78ac commit f9fc021
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
3 changes: 2 additions & 1 deletion sandbox/App.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import { App } from './src/App';
export default App;

export default App;
18 changes: 7 additions & 11 deletions sandbox/src/shadow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -803,20 +803,16 @@ function getResult({
// [web] [*3]: the width/height we get here is already rounded by RN, even if the real size according to the browser
// inspector is decimal. It will round up if (>= .5), else, down.
const eventLayout = e.nativeEvent.layout;
let newLayout: Size | undefined;
// Change layout state if the style width/height is undefined or 'x%', or the sizes in pixels are different.
if (
typeof styleWidth !== 'number' &&
(childLayout?.width === undefined || P(eventLayout.width) !== P(childLayout.width))
(typeof styleWidth !== 'number' &&
(childLayout?.width === undefined ||
P(eventLayout.width) !== P(childLayout.width))) ||
(typeof styleHeight !== 'number' &&
(childLayout?.height === undefined ||
P(eventLayout.height) !== P(childLayout.height)))
)
newLayout = { width: eventLayout.width, height: undefined };
if (
typeof styleHeight !== 'number' &&
(childLayout?.height === undefined || P(eventLayout.height) !== P(childLayout.height))
)
newLayout = { width: newLayout?.width, height: eventLayout.height };

if (newLayout) setChildLayout(newLayout);
setChildLayout({ width: eventLayout.width, height: eventLayout.height });
}}
{...childrenViewProps}
>
Expand Down
18 changes: 7 additions & 11 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -803,20 +803,16 @@ function getResult({
// [web] [*3]: the width/height we get here is already rounded by RN, even if the real size according to the browser
// inspector is decimal. It will round up if (>= .5), else, down.
const eventLayout = e.nativeEvent.layout;
let newLayout: Size | undefined;
// Change layout state if the style width/height is undefined or 'x%', or the sizes in pixels are different.
if (
typeof styleWidth !== 'number' &&
(childLayout?.width === undefined || P(eventLayout.width) !== P(childLayout.width))
(typeof styleWidth !== 'number' &&
(childLayout?.width === undefined ||
P(eventLayout.width) !== P(childLayout.width))) ||
(typeof styleHeight !== 'number' &&
(childLayout?.height === undefined ||
P(eventLayout.height) !== P(childLayout.height)))
)
newLayout = { width: eventLayout.width, height: undefined };
if (
typeof styleHeight !== 'number' &&
(childLayout?.height === undefined || P(eventLayout.height) !== P(childLayout.height))
)
newLayout = { width: newLayout?.width, height: eventLayout.height };

if (newLayout) setChildLayout(newLayout);
setChildLayout({ width: eventLayout.width, height: eventLayout.height });
}}
{...childrenViewProps}
>
Expand Down

0 comments on commit f9fc021

Please sign in to comment.