mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
b2452ab216
Summary: This PR aims to add support for objectFit a partial equivalent to the resizeMode style and prop of Image. ## Changelog [General] [Added] - Add support for objectFit style of Image. Pull Request resolved: https://github.com/facebook/react-native/pull/34576 Test Plan: 1. Open the RNTester app and navigate to the Image page 2. See the Object Fit section.  Reviewed By: rickhanlonii Differential Revision: D39261176 Pulled By: jacdebug fbshipit-source-id: 1eefd76b6c11ed5fc52b2c524ad78c91051077f6
22 lines
527 B
JavaScript
22 lines
527 B
JavaScript
/**
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @flow
|
|
* @format
|
|
*/
|
|
|
|
type ResizeMode = 'cover' | 'contain' | 'stretch' | 'repeat' | 'center';
|
|
|
|
export function convertObjectFitToResizeMode(objectFit: string): ResizeMode {
|
|
const objectFitMap = {
|
|
contain: 'contain',
|
|
cover: 'cover',
|
|
fill: 'stretch',
|
|
'scale-down': 'contain',
|
|
};
|
|
return objectFitMap[objectFit];
|
|
}
|