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

adjust touch logic for non-interactive images #55

Merged
merged 9 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
14 changes: 12 additions & 2 deletions src/modules/react-reconciler/Atlas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ export const Atlas: React.FC<

const { height: _, width: __, ...canvasProps } = restProps;
const widthClassName = useClassname([restProps.width, restProps.height]);
let isInteractive = true;
// if we have a render preset and that render preset sets interactive to false, then... disable it
if (renderPreset && Array.isArray(renderPreset) && renderPreset.length > 1 && (renderPreset[1] as any).interactive === false) {
isInteractive = false;
}
Comment on lines +448 to +452
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this a logical assumption, by default it's interactive, but if someone explicitly sets the presets to disable the interactivity, then it isn't


return (
<Container
Expand Down Expand Up @@ -483,7 +488,11 @@ export const Atlas: React.FC<
ref={refs.canvas as any}
/>
)}
<Container className="atlas-overlay" style={{ ...(overlayStyle || {}) }} ref={refs.overlay as any}>

<Container className={['atlas-overlay', isInteractive ? 'atlas-overlay--interactive' : null]
abrin marked this conversation as resolved.
Show resolved Hide resolved
abrin marked this conversation as resolved.
Show resolved Hide resolved
.filter(Boolean)
.join(' ')
.trim()} style={{ ...(overlayStyle || {}) }} ref={refs.overlay as any}>
{unstable_noReconciler ? (
<Canvas>
<BoundsContext.Provider value={bounds}>
Expand Down Expand Up @@ -526,7 +535,8 @@ export const Atlas: React.FC<
.atlas-canvas:focus-visible, .atlas-canvas-container:focus-visible { outline: var(--atlas-focus, 2px solid darkorange) }
.atlas-static-preset { touch-action: inherit; }
.atlas-static-container { position: relative; overflow: hidden; flex: 1 1 0px; }
.atlas-overlay { position: absolute; top: 0; left: 0; pointer-events: none; overflow: hidden; }
.atlas-overlay { position: absolute; top: 0; left: 0; none; overflow: hidden; }
.atlas-overlay--interactive { pointer-events: none; }
.atlas-static-image { position: absolute; pointer-events: none; user-select: none; transform-origin: 0px 0px; }
.atlas-navigator { position: absolute; top: var(--atlas-navigator-top, 10px); right: var(--atlas-navigator-bottom, 10px); left: var(--atlas-navigator-left); bottom: var(--atlas-navigator-bottom); opacity: .8 }
.atlas-navigator-canvas { width: 100%; }
Expand Down
2 changes: 1 addition & 1 deletion stories/homepage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const StaticRendererPreset = () => {
width={400}
height={400}
key={c ? 'a' : 'b'}
renderPreset={['static-preset', { canvasBox: c }]}
renderPreset={['static-preset', { canvasBox: c, interactive: false }]}
onCreated={(rt) => rt.runtime?.world.gotoRegion({ x: 0, y: 0, width: 300, height: 300, immediate: true })}
>
{boxes}
Expand Down