-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Prevent stale values when a binding's bound object changes.
- Loading branch information
1 parent
a6c5ad3
commit 610f3db
Showing
4 changed files
with
141 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<script lang="ts"> | ||
import { Binding, List } from '$lib'; | ||
import AutoObject from '$lib/extra/AutoObject.svelte'; | ||
let testObjectA = { | ||
someBoolean: true, | ||
someColor: { | ||
r: 255, | ||
g: 0, | ||
b: 55 | ||
}, | ||
someFolder: { | ||
b: 2, | ||
a: 1, | ||
c: 3 | ||
}, | ||
someNumber: 1, | ||
somePoint: { | ||
x: 1, | ||
y: 2 | ||
}, | ||
someString: 'test' | ||
}; | ||
let testObjectB = { | ||
someBoolean: false, | ||
someFolder: { | ||
r: 3, | ||
b: 2, | ||
a: 1, | ||
c: 3, | ||
d: 4, | ||
e: 5 | ||
}, | ||
someNumber: 3, | ||
someOtherColor: { | ||
r: 0, | ||
g: 55, | ||
b: 55 | ||
}, | ||
someOtherPoint: { | ||
x: 1, | ||
y: 2, | ||
z: 2, | ||
f: 3 | ||
}, | ||
someString: 'test' | ||
}; | ||
const testOptions = { b: testObjectA, a: testObjectB }; | ||
let activeObject = testObjectA; | ||
$: { | ||
console.log('activeObject', activeObject); | ||
} | ||
</script> | ||
|
||
// Noticed issues with re-assigning the object when working on Tweakpane CSS with STUI version 1.2.6 | ||
|
||
<List bind:value={activeObject} options={testOptions} /> | ||
<hr /> | ||
<Binding bind:object={activeObject} key="someBoolean" /> | ||
<hr /> | ||
<Binding bind:object={activeObject} key="someNumber" /> | ||
<hr /> | ||
<AutoObject bind:object={activeObject} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<script lang="ts"> | ||
import { | ||
AutoValue, | ||
type BindingObject, | ||
ButtonGrid, | ||
Checkbox, | ||
Pane, | ||
Separator, | ||
Slider | ||
} from '$lib'; | ||
import Button from '$lib/control/Button.svelte'; | ||
import Folder from '$lib/core/Folder.svelte'; | ||
let testObject = { | ||
someColor: { | ||
r: 255, | ||
g: 0, | ||
b: 55 | ||
}, | ||
someOtherColor: { | ||
r: 0, | ||
g: 255, | ||
b: 55 | ||
} | ||
} as BindingObject; | ||
let showNumbers = true; | ||
let folderWrap = false; | ||
let someNumber = 1; | ||
</script> | ||
|
||
<Pane> | ||
{#if folderWrap} | ||
<Folder> | ||
{#each Object.keys(testObject) as key} | ||
{#if typeof testObject[key] !== 'number' || showNumbers} | ||
<AutoValue bind:value={testObject[key]} label={key} /> | ||
{/if} | ||
{/each} | ||
</Folder> | ||
<Slider bind:value={someNumber} label="Some Number" /> | ||
{:else} | ||
{#each Object.keys(testObject) as key} | ||
{#if typeof testObject[key] !== 'number' || showNumbers} | ||
<AutoValue bind:value={testObject[key]} label={key} /> | ||
{/if} | ||
{/each} | ||
<Slider bind:value={someNumber} label="Some Number" /> | ||
{/if} | ||
<Separator /> | ||
<ButtonGrid buttons={['Copy', 'Reset']} /> | ||
<Folder expanded={false} title="Tweakpane CSS Options"> | ||
<Checkbox bind:value={showNumbers} label="Show Numbers" /> | ||
<Checkbox bind:value={folderWrap} label="Folder Wrap" /> | ||
</Folder> | ||
<Button /> | ||
</Pane> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters