Skip to content
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
7 changes: 6 additions & 1 deletion src/frontend/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
font-display: swap;
}

/* CSS Variables */
:root {
--embeddable-pointer-events: all;
}

/* Override Excalidraw styles */

body {
Expand Down Expand Up @@ -77,6 +82,6 @@ body {

.excalidraw__embeddable__outer { /* 3rd layer */
padding: 0px !important;
pointer-events: all !important;
pointer-events: var(--embeddable-pointer-events, all) !important;
display: flex;
}
22 changes: 22 additions & 0 deletions src/frontend/src/CustomEmbeddableRenderer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { debounce } from './utils/debounce';
import type { NonDeleted, ExcalidrawEmbeddableElement } from '@atyrode/excalidraw/element/types';
import type { AppState } from '@atyrode/excalidraw/types';
import {
Expand Down Expand Up @@ -85,3 +86,24 @@ export const renderCustomEmbeddable = (
);
}
};

// Track scrolling state
let isScrolling = false;

export const lockEmbeddables = () => {
if (!isScrolling) {
isScrolling = true;
// Set pointer-events to none during scrolling
document.documentElement.style.setProperty('--embeddable-pointer-events', 'none');
}

// Reset the pointer-events after scrolling stops
debouncedScrollEnd();
};

// Create a debounced function to detect when scrolling ends
const debouncedScrollEnd = debounce(() => {
isScrolling = false;
// Set pointer-events back to all when not scrolling
document.documentElement.style.setProperty('--embeddable-pointer-events', 'all');
}, 150); // 150ms debounce seems reasonable, but can be adjusted as needed
5 changes: 4 additions & 1 deletion src/frontend/src/ExcalidrawWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ExcalidrawImperativeAPI } from '@atyrode/excalidraw/types';
import type { NonDeletedExcalidrawElement } from '@atyrode/excalidraw/element/types';
import type { AppState } from '@atyrode/excalidraw/types';
import { MainMenuConfig } from './ui/MainMenu';
import { renderCustomEmbeddable } from './CustomEmbeddableRenderer';
import { lockEmbeddables, renderCustomEmbeddable } from './CustomEmbeddableRenderer';
import AuthDialog from './ui/AuthDialog';
import BackupsModal from './ui/BackupsDialog';

Expand All @@ -25,6 +25,7 @@ interface ExcalidrawWrapperProps {
setExcalidrawAPI: (api: ExcalidrawImperativeAPI) => void;
initialData?: any;
onChange: (elements: NonDeletedExcalidrawElement[], state: AppState) => void;
onScrollChange: (scrollX: number, scrollY: number) => void;
MainMenu: any;
renderTopRightUI?: () => React.ReactNode;
isAuthenticated?: boolean | null;
Expand All @@ -37,6 +38,7 @@ export const ExcalidrawWrapper: React.FC<ExcalidrawWrapperProps> = ({
setExcalidrawAPI,
initialData,
onChange,
onScrollChange,
MainMenu,
renderTopRightUI,
isAuthenticated = null,
Expand Down Expand Up @@ -80,6 +82,7 @@ export const ExcalidrawWrapper: React.FC<ExcalidrawWrapperProps> = ({
initialData: initialData ?? defaultInitialData,
onChange: onChange,
name: "Pad.ws",
onScrollChange: lockEmbeddables,
validateEmbeddable: true,
renderEmbeddable: (element, appState) => renderCustomEmbeddable(element, appState, excalidrawAPI),
renderTopRightUI: renderTopRightUI ?? (() => (
Expand Down