Skip to content

Commit 99d5f13

Browse files
fix: Color picker lagging when switching between Jelly examples (#2340)
1 parent 969902e commit 99d5f13

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

apps/typegpu-docs/src/components/ExampleView.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import cs from 'classnames';
22
import { useAtom, useAtomValue, useSetAtom } from 'jotai';
3-
import { type RefObject, useEffect, useRef, useState } from 'react';
3+
import { type RefObject, useEffect, useLayoutEffect, useRef, useState } from 'react';
44
import { currentSnackbarAtom } from '../utils/examples/currentSnackbarAtom.ts';
55
import { codeEditorShownAtom, tsoverUsedAtom } from '../utils/examples/exampleViewStateAtoms.ts';
66
import { ExecutionCancelledError } from '../utils/examples/errors.ts';
@@ -28,9 +28,10 @@ function useExample(
2828
const exampleRef = useRef<ExampleState | null>(null);
2929
const setExampleControlParams = useSetAtom(exampleControlsAtom);
3030

31-
useEffect(() => {
31+
useLayoutEffect(() => {
3232
let cancelled = false;
3333
setSnackbarText(undefined);
34+
setExampleControlParams([]);
3435

3536
executeExample(tsImport)
3637
.then((example) => {

apps/typegpu-docs/src/examples/rendering/jelly-slider/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"title": "Jelly slider",
2+
"title": "Jelly Slider",
33
"category": "rendering",
44
"tags": ["interaction", "ray marching", "sdf", "ui"],
55
"coolFactor": 10

0 commit comments

Comments
 (0)