Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add experimental prop _experimentDisableItemAnimation #88

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions src/components/DashKit/DashKit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {OverlayControlItem} from '../OverlayControls/OverlayControls';
interface DashKitGeneralProps {
config: Config;
editMode: boolean;
draggableHandleClassName?: string;
overlayControls?: Record<string, OverlayControlItem[]>;
}

interface DashKitDefaultProps {
Expand All @@ -30,9 +32,9 @@ interface DashKitDefaultProps {
itemsStateAndParams: ItemsStateAndParams;
settings: SettingsProps;
context: ContextProps;
overlayControls?: Record<string, OverlayControlItem[]>;
noOverlay?: boolean;
draggableHandleClassName?: string;
noOverlay: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change it from optional to required? Looks like breaking change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know who added it, but if some props are in DashKitDefaultProps it means that props should have values

// it will be deleted soon
_experimentDisableItemAnimation: boolean;
}

export interface DashKitProps extends DashKitGeneralProps, Partial<DashKitDefaultProps> {}
Expand All @@ -54,6 +56,7 @@ export class DashKit extends React.PureComponent<DashKitInnerProps> {
},
context: {},
noOverlay: false,
_experimentDisableItemAnimation: false,
};

static registerPlugins(...plugins: Plugin[]) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/GridItem/GridItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class GridItem extends React.PureComponent {
noOverlay,
withCustomHandle,
} = this.props;
const {editMode} = this.context;
const {editMode, _experimentDisableItemAnimation} = this.context;
const width = Number.parseInt(style.width, 10);
const height = Number.parseInt(style.height, 10);
const transform = style.transform;
Expand All @@ -93,6 +93,7 @@ class GridItem extends React.PureComponent {
{
'is-dragging': isDragging,
'with-custom-handle': withCustomHandle,
'disable-animation': _experimentDisableItemAnimation,
},
preparedClassName,
)}
Expand Down
4 changes: 4 additions & 0 deletions src/components/GridItem/GridItem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
.react-grid-item {
transition: all 200ms ease;
transition-property: left, top;

&.dashkit-grid-item_disable-animation {
transition: none;
}
}

.react-grid-item.cssTransforms {
Expand Down
2 changes: 2 additions & 0 deletions src/hocs/withContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ function useMemoStateContext(props) {
revertToOriginalLayout,
forwardedMetaRef: props.forwardedMetaRef,
draggableHandleClassName: props.draggableHandleClassName,
_experimentDisableItemAnimation: props._experimentDisableItemAnimation,
}),
[
resultLayout,
Expand All @@ -220,6 +221,7 @@ function useMemoStateContext(props) {
revertToOriginalLayout,
props.forwardedMetaRef,
props.draggableHandleClassName,
props._experimentDisableItemAnimation,
],
);
}
Expand Down