Skip to content

Commit

Permalink
fix the Sortable > Customization demo (#3113)
Browse files Browse the repository at this point in the history
* fix the Sortable > Customization demo

* save a flag not a component in the state
  • Loading branch information
VasilyStrelyaev authored Jan 19, 2024
1 parent 5130d5a commit 594f5c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions JSDemos/Demos/Sortable/Customization/React/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const App = () => {
const [scrollSpeed, setScrollSpeed] = useState(30);
const [scrollSensitivity, setScrollSensitivity] = useState(60);
const [handle, setHandle] = useState('');
const [dragComponent, setDragComponent] = useState(null);
const [useDragComponent, setUseDragComponent] = useState(false);
const [cursorOffset, setCursorOffset] = useState(null);

const onDragStart = useCallback((e: SortableTypes.DragStartEvent) => {
Expand Down Expand Up @@ -73,9 +73,9 @@ const App = () => {
}, [setHandle]);

const onDragTemplateChanged = useCallback((e: CheckBoxTypes.ValueChangedEvent) => {
setDragComponent(e.value ? DragItem : null);
setUseDragComponent(!!e.value);
setCursorOffset(e.value ? { x: 10, y: 20 } : null);
}, [setDragComponent, setCursorOffset]);
}, [setUseDragComponent, setCursorOffset]);

return (
<div id="demo-container">
Expand All @@ -94,7 +94,7 @@ const App = () => {
scrollSpeed={scrollSpeed}
scrollSensitivity={scrollSensitivity}
handle={handle}
dragComponent={dragComponent}
dragComponent={useDragComponent ? DragItem : null}
cursorOffset={cursorOffset}
onDragStart={onDragStart}
onReorder={onReorder}
Expand Down
8 changes: 4 additions & 4 deletions JSDemos/Demos/Sortable/Customization/ReactJs/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const App = () => {
const [scrollSpeed, setScrollSpeed] = useState(30);
const [scrollSensitivity, setScrollSensitivity] = useState(60);
const [handle, setHandle] = useState('');
const [dragComponent, setDragComponent] = useState(null);
const [useDragComponent, setUseDragComponent] = useState(false);
const [cursorOffset, setCursorOffset] = useState(null);
const onDragStart = useCallback(
(e) => {
Expand Down Expand Up @@ -86,10 +86,10 @@ const App = () => {
);
const onDragTemplateChanged = useCallback(
(e) => {
setDragComponent(e.value ? DragItem : null);
setUseDragComponent(!!e.value);
setCursorOffset(e.value ? { x: 10, y: 20 } : null);
},
[setDragComponent, setCursorOffset],
[setUseDragComponent, setCursorOffset],
);
return (
<div id="demo-container">
Expand All @@ -108,7 +108,7 @@ const App = () => {
scrollSpeed={scrollSpeed}
scrollSensitivity={scrollSensitivity}
handle={handle}
dragComponent={dragComponent}
dragComponent={useDragComponent ? DragItem : null}
cursorOffset={cursorOffset}
onDragStart={onDragStart}
onReorder={onReorder}
Expand Down

0 comments on commit 594f5c3

Please sign in to comment.