Skip to content

Commit a01ba86

Browse files
committed
fix: set transformOrigin only for mobile
1 parent d3cb160 commit a01ba86

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

src/components/Button/Button.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ const Button = (
220220
);
221221
const { roundness, isV3, animation } = theme;
222222
const uppercase = uppercaseProp ?? !theme.isV3;
223+
const isWeb = Platform.OS === 'web';
223224

224225
const hasPassedTouchHandler = hasTouchHandler({
225226
onPress,
@@ -255,8 +256,7 @@ const Button = (
255256
toValue: activeElevation,
256257
duration: 200 * scale,
257258
useNativeDriver:
258-
Platform.OS === 'web' ||
259-
Platform.constants.reactNativeVersion.minor <= 72,
259+
isWeb || Platform.constants.reactNativeVersion.minor <= 72,
260260
}).start();
261261
}
262262
};
@@ -269,8 +269,7 @@ const Button = (
269269
toValue: initialElevation,
270270
duration: 150 * scale,
271271
useNativeDriver:
272-
Platform.OS === 'web' ||
273-
Platform.constants.reactNativeVersion.minor <= 72,
272+
isWeb || Platform.constants.reactNativeVersion.minor <= 72,
274273
}).start();
275274
}
276275
};

src/components/Chip/Chip.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ const Chip = ({
213213
}: Props) => {
214214
const theme = useInternalTheme(themeOverrides);
215215
const { isV3, roundness } = theme;
216+
const isWeb = Platform.OS === 'web';
216217

217218
const { current: elevation } = React.useRef<Animated.Value>(
218219
new Animated.Value(isV3 && elevated ? 1 : 0)
@@ -234,8 +235,7 @@ const Chip = ({
234235
toValue: isV3 ? (elevated ? 2 : 0) : 4,
235236
duration: 200 * scale,
236237
useNativeDriver:
237-
Platform.OS === 'web' ||
238-
Platform.constants.reactNativeVersion.minor <= 72,
238+
isWeb || Platform.constants.reactNativeVersion.minor <= 72,
239239
}).start();
240240
});
241241

@@ -246,8 +246,7 @@ const Chip = ({
246246
toValue: isV3 && elevated ? 1 : 0,
247247
duration: 150 * scale,
248248
useNativeDriver:
249-
Platform.OS === 'web' ||
250-
Platform.constants.reactNativeVersion.minor <= 72,
249+
isWeb || Platform.constants.reactNativeVersion.minor <= 72,
251250
}).start();
252251
});
253252

src/components/TextInput/Label/InputLabel.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ const InputLabel = (props: InputLabelProps) => {
5656
const { INPUT_PADDING_HORIZONTAL } = getConstants(isV3);
5757
const { width } = useWindowDimensions();
5858

59+
const isWeb = Platform.OS === 'web';
60+
5961
const paddingOffset =
6062
paddingLeft && paddingRight ? { paddingLeft, paddingRight } : {};
6163

@@ -111,9 +113,10 @@ const InputLabel = (props: InputLabelProps) => {
111113
: labeled,
112114
},
113115
],
114-
...(Platform.constants.reactNativeVersion.minor >= 73 && {
115-
transformOrigin: 'left',
116-
}),
116+
...(!isWeb &&
117+
Platform.constants.reactNativeVersion.minor >= 73 && {
118+
transformOrigin: 'left',
119+
}),
117120
};
118121

119122
const labelWidth =
@@ -147,9 +150,9 @@ const InputLabel = (props: InputLabelProps) => {
147150
pointerEvents="none"
148151
style={[
149152
StyleSheet.absoluteFill,
150-
Platform.OS !== 'web' && { width },
153+
!isWeb && { width },
151154
{ opacity },
152-
Platform.constants.reactNativeVersion.minor <= 72 &&
155+
(isWeb || Platform.constants.reactNativeVersion.minor <= 72) &&
153156
labelTranslationX,
154157
]}
155158
>

src/components/TextInput/Label/LabelBackground.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const LabelBackground = ({
1717
maxFontSizeMultiplier,
1818
testID,
1919
}: LabelBackgroundProps) => {
20+
const isWeb = Platform.OS === 'web';
21+
2022
const opacity = labeled.interpolate({
2123
inputRange: [0, 0.6],
2224
outputRange: [1, 0],
@@ -52,7 +54,7 @@ const LabelBackground = ({
5254
bottom: Math.max(roundness, 2),
5355
opacity,
5456
},
55-
Platform.constants.reactNativeVersion.minor <= 72 && {
57+
(isWeb || Platform.constants.reactNativeVersion.minor <= 72) && {
5658
transform: [labelTranslationX],
5759
},
5860
]}

0 commit comments

Comments
 (0)