Skip to content

Commit 508b577

Browse files
committed
WIP
1 parent 653785e commit 508b577

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

demo/src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ function App() {
330330
}
331331
showErrorMessages={dataDefinition.showErrorMessages}
332332
collapse={collapseLevel}
333+
// collapseAnimationTime={100}
333334
showCollectionCount={
334335
showCount === 'Yes' ? true : showCount === 'When closed' ? 'when-closed' : false
335336
}

src/JsonEditor.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const Editor: React.FC<JsonEditorProps> = ({
3737
enableClipboard = true,
3838
indent = 3,
3939
collapse = false,
40+
collapseAnimationTime,
4041
showCollectionCount = true,
4142
restrictEdit = false,
4243
restrictDelete = false,
@@ -72,6 +73,17 @@ const Editor: React.FC<JsonEditorProps> = ({
7273

7374
const [data, setData] = useData<JsonData>({ setData: srcSetData, data: srcData })
7475

76+
const docRoot = document.querySelector(':root') as HTMLElement
77+
const transitionTime = getComputedStyle(document.documentElement).getPropertyValue(
78+
'--jer-expand-transition-time'
79+
)
80+
if (
81+
collapseAnimationTime !== undefined &&
82+
parseFloat(transitionTime) * 1000 !== collapseAnimationTime
83+
) {
84+
docRoot?.style.setProperty('--jer-expand-transition-time', `${collapseAnimationTime / 1000}s`)
85+
}
86+
7587
useEffect(() => {
7688
const debounce = setTimeout(() => setDebouncedSearchText(searchText), searchDebounceTime)
7789
return () => clearTimeout(debounce)

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface JsonEditorProps {
2222
id?: string
2323
indent?: number
2424
collapse?: boolean | number | FilterFunction
25+
collapseAnimationTime?: number // ms
2526
showCollectionCount?: boolean | 'when-closed'
2627
restrictEdit?: boolean | FilterFunction
2728
restrictDelete?: boolean | FilterFunction

0 commit comments

Comments
 (0)