You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example in the docs explaining the position property works fine (link).
However, when the options object is passed, the dragged element doesn't update programmatically.
For instance, the code below does not make the dragged element to get back to its original position when released.
<script>
import { draggable } from'@neodrag/svelte'let position = { x:0, y:0 };let options = { position,onDrag: ({ offsetX, offsetY }) => { position = { x: offsetX, y: offsetY }; },onDragEnd: ({ offsetX, offsetY }) => { position = { x:0, y:0 }; } }
</script>
<divclass="drag"use:draggable={options}>
I can be moved with the slider too
</div>
X: <inputtype="range"min="0"max="300"bind:value={position.x} />
Y: <inputtype="range"min="0"max="300"bind:value={position.y} />
However, the code below does.
<script>
import { draggable } from'@neodrag/svelte'let position = { x:0, y:0 }
</script>
<divclass="drag"use:draggable={{
position,
onDrag: ({ offsetX, offsetY }) => {
position= { x: offsetX, y: offsetY };
},
onDragEnd: ({ offsetX, offsetY }) => {
position= { x: 0, y: 0 }
}
}}>
I can be moved with the slider too
</div>
X: <inputtype="range"min="0"max="300"bind:value={position.x} />
Y: <inputtype="range"min="0"max="300"bind:value={position.y} />
Version: 2.0.3
Framework: Svelte
The text was updated successfully, but these errors were encountered:
amccampos
changed the title
position property is not biding when the options object is on script (svelte version)
position property is not biding when the options object is in the script (svelte version)
Feb 23, 2023
The example in the docs explaining the
position
property works fine (link).However, when the options object is passed, the dragged element doesn't update programmatically.
For instance, the code below does not make the dragged element to get back to its original position when released.
However, the code below does.
Version: 2.0.3
Framework: Svelte
The text was updated successfully, but these errors were encountered: