Closed vrbhartiya closed 4 years ago
@vrbhartiya Thank you It seems to be added like this.
moveable.setState({
target: event.target,
}, () => {
this.moveable.dragStart(e);
});
Thanks for the quick response. Just to clarify, is setState
a function that already exists or something you'll need to add?
setState is the way React, manages state, pre-hooks, https://reactjs.org/docs/state-and-lifecycle.html
@vrbhartiya I'll add method. maybe this week? 11.9?
@Marius8881
Of course I know. setState
will be used in vanilla, angular, and svelte, not react, preact.
Yeah, that sounds good. Thanks!
@vrbhartiya
moveable
0.10.0 is released.
you can use setState
method.
moveable.setState({
target: target2
}, () => {
moveable.dragStart(e);
});
thank you :)
Thanks!
@daybrush Hi, thanks in advance for this wonderful package. question: when I select target and start draging at the same time, item moves but flashes a little, but if I select target in one event and start drag in another event, item doesn't flash, Do you have any idea why this happens?
Hello, I'm trying to use a single moveable object for multiple elements. Based on #55, I've implemented the changing of the
target
property when one of the elements is clicked. However, I'd also like to be able to change the target and start dragging in a singlemousedown
event. TheMoveable.dragStart
method added for #10 is almost enough to do what I want, but I can't change the target and calldragStart
in the same function.To my current understanding of the codebase, this is because the change in target is only processed on
render
with thecheckState
function. So, if I queue thedragStart
using adelay(0)
it behaves as I expect.However, this is obviously a hack. It would be much better if there was a way to force the update, or even a method to change targets instead of direct assignment (eg.
Moveable.changeTarget(newTarget:SVGElement | HTMLElement | Array<SVGElement | HTMLElement>)
) .Would it be possible to add something in the
Moveable
class' public API to achieve this?