Skip to content

Commit

Permalink
fix: remove effective scroll action
Browse files Browse the repository at this point in the history
  • Loading branch information
dubloom authored and guyb1 committed Sep 7, 2024
1 parent a69b241 commit 1c6786b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/context/scroll-context/scroll-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ export type ScrollActionType = 'pan' | 'zoom';
export interface ScrollContext {
scrollAction: ScrollActionType;
setScrollAction: (action: ScrollActionType) => void;
effectiveScrollAction: ScrollActionType;
}

export const ScrollContext = createContext<ScrollContext>({
scrollAction: 'pan',
setScrollAction: emptyFn,
effectiveScrollAction: 'pan',
});
9 changes: 1 addition & 8 deletions src/context/scroll-context/scroll-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ export const ScrollProvider: React.FC<React.PropsWithChildren> = ({
return savedAction || 'pan';
});

const [effectiveScrollAction, setEffectiveScrollAction] =
useState<ScrollActionType>('pan');

useEffect(() => {
console.log('coucou');
localStorage.setItem('scrollAction', scrollAction);
setEffectiveScrollAction(scrollAction);
}, [scrollAction]);

return (
<ScrollContext.Provider
value={{ scrollAction, setScrollAction, effectiveScrollAction }}
>
<ScrollContext.Provider value={{ scrollAction, setScrollAction }}>
{children}
</ScrollContext.Provider>
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/editor-page/canvas/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
} = useChartDB();
const { showSidePanel } = useLayout();
const { effectiveTheme } = useTheme();
const { effectiveScrollAction } = useScrollAction();
const { scrollAction } = useScrollAction();
const { isMd: isDesktop } = useBreakpoint('md');
const nodeTypes = useMemo(() => ({ table: TableNode }), []);
const edgeTypes = useMemo(() => ({ 'table-edge': TableEdge }), []);
Expand Down Expand Up @@ -287,7 +287,7 @@ export const Canvas: React.FC<CanvasProps> = ({ initialTables }) => {
animated: false,
type: 'table-edge',
}}
panOnScroll={effectiveScrollAction === 'pan'}
panOnScroll={scrollAction === 'pan'}
>
{isLoadingDOM ? (
<Controls
Expand Down

0 comments on commit 1c6786b

Please sign in to comment.