Skip to content

Commit 1056ed1

Browse files
committed
Configurable open/close animation
1 parent 7ddf58f commit 1056ed1

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ Default:
4848
```
4949
Available configurations:
5050
##### Hover Preview
51-
* `hoverPreviewEnabled`: enable preview on hover
51+
* `hoverPreviewEnabled`: enable preview on hover.
5252
* `hoverPreviewArrayCount`: number of array items to show in preview Any array larger than this number will be shown as `Array[XXX]` where `XXX` is length of the array.
5353
* `hoverPreviewFieldCount`: number of object properties to show for object preview. Any object with more properties that thin number will be truncated.
54+
* `animateOpen`: enable animation when expanding json object. True by default.
55+
* `animateClose`: enable animation when closing json object. True by default.
5456

5557
##### Theme
5658
* `theme`: a string that can be any of these options: `['dark']`. Look at [`src/style.less`](src/style.less) for making new themes.

dist/bundle.js

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,17 @@ interface JSONFormatterConfiguration {
2424
hoverPreviewEnabled: boolean;
2525
hoverPreviewArrayCount: number;
2626
hoverPreviewFieldCount: number;
27+
animateOpen: boolean;
28+
animateClose: boolean;
2729
theme: string;
2830
};
2931

3032
const _defaultConfig: JSONFormatterConfiguration = {
3133
hoverPreviewEnabled: false,
3234
hoverPreviewArrayCount: 100,
3335
hoverPreviewFieldCount: 5,
36+
animateOpen: true,
37+
animateClose: true,
3438
theme: null
3539
};
3640

@@ -197,9 +201,9 @@ export = class JSONFormatter {
197201
this.isOpen = !this.isOpen;
198202

199203
if (this.isOpen) {
200-
this.appendChildern(true);
204+
this.appendChildern(this.config.animateOpen);
201205
} else{
202-
this.removeChildren(true);
206+
this.removeChildren(this.config.animateClose);
203207
}
204208

205209
if (this.element) {

0 commit comments

Comments
 (0)