Skip to content

Commit cf11e80

Browse files
added autoHeight and aspectRatio options in json lottie
1 parent ba10433 commit cf11e80

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

client/packages/lowcoder/src/comps/comps/jsonComp/jsonLottieComp.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { hiddenPropertyView, showDataLoadingIndicatorsPropertyView } from "comps
22
import {
33
ArrayOrJSONObjectControl,
44
NumberControl,
5+
StringControl,
56
} from "comps/controls/codeControl";
67
import { dropdownControl } from "comps/controls/dropdownControl";
78
import { BoolControl } from "comps/controls/boolControl";
@@ -20,6 +21,7 @@ import { defaultLottie } from "./jsonConstants";
2021
import { EditorContext } from "comps/editorState";
2122
import { AssetType, IconscoutControl } from "@lowcoder-ee/comps/controls/iconscoutControl";
2223
import { DotLottie } from "@lottiefiles/dotlottie-react";
24+
import { AutoHeightControl } from "@lowcoder-ee/comps/controls/autoHeightControl";
2325

2426
// const Player = lazy(
2527
// () => import('@lottiefiles/react-lottie-player')
@@ -112,6 +114,8 @@ let JsonLottieTmpComp = (function () {
112114
animationStart: dropdownControl(animationStartOptions, "auto"),
113115
loop: dropdownControl(loopOptions, "single"),
114116
keepLastFrame: BoolControl.DEFAULT_TRUE,
117+
autoHeight: withDefault(AutoHeightControl, "fixed"),
118+
aspectRatio: withDefault(StringControl, "16 / 9"),
115119
};
116120
return new UICompBuilder(childrenMap, (props, dispatch) => {
117121
const [dotLottie, setDotLottie] = useState<DotLottie | null>(null);
@@ -151,6 +155,7 @@ let JsonLottieTmpComp = (function () {
151155
background: `${props.container.background}`,
152156
padding: `${props.container.padding}`,
153157
rotate: props.container.rotation,
158+
aspectRatio: props.aspectRatio,
154159
}}
155160
>
156161
<DotLottiePlayer
@@ -171,6 +176,9 @@ let JsonLottieTmpComp = (function () {
171176
}}
172177
onMouseEnter={() => props.animationStart === "hover" && dotLottie?.play()}
173178
onMouseLeave={() => props.animationStart === "hover" && dotLottie?.pause()}
179+
renderConfig={{
180+
autoResize: props.autoHeight,
181+
}}
174182
/>
175183
</div>
176184
</div>
@@ -204,6 +212,15 @@ let JsonLottieTmpComp = (function () {
204212
</>
205213
)}
206214

215+
{["layout", "both"].includes(useContext(EditorContext).editorModeStatus) && (
216+
<Section name={sectionNames.layout}>
217+
{children.autoHeight.getPropertyView()}
218+
{children.aspectRatio.propertyView({
219+
label: trans("style.aspectRatio"),
220+
})}
221+
</Section>
222+
)}
223+
207224
{(useContext(EditorContext).editorModeStatus === "layout" || useContext(EditorContext).editorModeStatus === "both") && (
208225
<>
209226
<Section name={sectionNames.style}>
@@ -221,7 +238,7 @@ let JsonLottieTmpComp = (function () {
221238
})();
222239
JsonLottieTmpComp = class extends JsonLottieTmpComp {
223240
override autoHeight(): boolean {
224-
return false;
241+
return this.children.autoHeight.getView();
225242
}
226243
};
227244
export const JsonLottieComp = withExposingConfigs(JsonLottieTmpComp, [

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy