Skip to content

Commit d766a34

Browse files
committed
designed formula to calculate padding dynamically
1 parent 3cedced commit d766a34

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

client/packages/lowcoder/src/comps/comps/imageComp.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ const childrenMap = {
169169
animationStyle: styleControl(AnimationStyle),
170170
autoHeight: withDefault(AutoHeightControl, "fixed"),
171171
supportPreview: BoolControl,
172+
restrictPaddingOnRotation:withDefault(BoolControl, true)
172173
};
173174

174175
let ImageBasicComp = new UICompBuilder(childrenMap, (props) => {

client/packages/lowcoder/src/comps/generators/uiCompBuilder.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ function UIView(props: {
248248

249249
let defaultChildren = comp.children;
250250
const isNotContainer = defaultChildren.hasOwnProperty('style');
251+
const restrictPaddingOnRotation = defaultChildren.hasOwnProperty('restrictPaddingOnRotation');
251252
let rotationVal = null
252253
let boxShadowVal = null;
253254
if (isNotContainer) {
@@ -263,17 +264,24 @@ function UIView(props: {
263264
width: '100%',
264265
height: '100%',
265266
margin: '0px',
266-
padding:
267-
rotationVal === null || rotationVal === undefined
268-
? '0px'
269-
: boxShadowVal === null || boxShadowVal === undefined
270-
? rotationVal === '' || rotationVal === '0deg'
271-
? '0px'
272-
: '50% 0px'
273-
: (rotationVal === '' || rotationVal === '0deg') &&
274-
(boxShadowVal === '' || boxShadowVal === '0px')
275-
? '0px'
276-
: '50% 0px',
267+
// padding:'0px',
268+
padding: (
269+
rotationVal === null || rotationVal === undefined || restrictPaddingOnRotation
270+
? '0px'
271+
: (
272+
boxShadowVal === null || boxShadowVal === undefined
273+
? (
274+
rotationVal === '' || rotationVal === '0deg'
275+
? '0px'
276+
: `calc(min(50%, ${Math.min(50, Math.abs(rotationVal.replace('deg', '')) / 90) * 100}%)) 0px`
277+
)
278+
: (
279+
(rotationVal === '' || rotationVal === '0deg') && (boxShadowVal === '' || boxShadowVal === '0px')
280+
? '0px'
281+
: `calc(min(50%, ${Math.min(50, Math.abs(rotationVal.replace('deg', '')) / 90) * 100}%)) 0px`
282+
)
283+
)
284+
)
277285
}}
278286
>
279287
<HidableView hidden={childrenProps.hidden as boolean}>

0 commit comments

Comments
 (0)