Skip to content
This repository was archived by the owner on Dec 2, 2021. It is now read-only.

Feat: added disableResize prop #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/TagCloud.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface ITagCloudProps {
| "rectangular"
| ((size: number) => (t: number) => [number, number]);
random?: () => number;
disableResize: boolean;
}

interface ITagCloudState {
Expand Down Expand Up @@ -53,6 +54,7 @@ class TagCloud extends React.Component<ITagCloudProps, ITagCloudState> {
]),
padding: PropTypes.oneOfType([PropTypes.func, PropTypes.number]),
}),
disableResize: PropTypes.bool,
};

public static defaultProps = {
Expand All @@ -66,6 +68,7 @@ class TagCloud extends React.Component<ITagCloudProps, ITagCloudState> {
fontWeight: "normal",
padding: 1,
},
disableResize: false,
};
public state = {
children: undefined,
Expand Down Expand Up @@ -260,6 +263,10 @@ class TagCloud extends React.Component<ITagCloudProps, ITagCloudState> {
return;
}

if (this.props.disableResize) {
return;
}

// Handle resizes with a debounce timeout of 100ms
if (this.resizeTimer) {
clearTimeout(this.resizeTimer);
Expand Down