fix: don't update based on parent offset on mount#920
fix: don't update based on parent offset on mount#920dan-cooke wants to merge 3 commits intobokuweb:masterfrom
Conversation
* I'm not sure if this will work for all use cases, but for me it is workig much better, before this fix there was an issue when the component position was stored externally and the component is remounted with a defaultPos - it will jump by the parent offset pixels, which just isn't right. In my eyes it should just use the exact position passed to it from consumers as the starting position, if a consumer wants to use the absolute value they can pass that, otherwise the position they use `lastX` `lastY` for example is relative to the parent anyway. So whats the point of applying this offset to those values?
|
@dan-cooke Thanks! I'll check it. |
src/index.tsx
Outdated
| const pos = this.state.resizing ? undefined : draggablePosition; | ||
| const dragAxisOrUndefined = this.state.resizing ? "both" : dragAxis; | ||
|
|
||
| console.log(defaultValue, pos); |
…ect-offset-calculation
|
@dan-cooke Thanks. I fixed #910, It was due to a different cause.so I don't understand your issue. Could you provide a reproduction in CodeSandbox if possible?" If the following actions are taken, will the problem be resolved? componentDidMount() {
if (this.props.position) return; // <- skip if position passed.
this.updateOffsetFromParent();
const { left, top } = this.offsetFromParent;
const { x, y } = this.getDraggablePosition();
this.draggable.setState({
x: x - left,
y: y - top,
});
// HACK: Apply position adjustment
this.forceUpdate();
} |
|
Let me check out the fix for 910 to see if it also fixes my issue, I’ll get
back to you as soon as I can
Thanks!
…On Sun, 21 Apr 2024 at 01:09, bokuweb ***@***.***> wrote:
@dan-cooke <https://github.com/dan-cooke> Thanks. I fixed #910
<#910>, It was due to a
different cause.so I don't understand your issue. Could you provide a
reproduction in CodeSandbox if possible?"
—
Reply to this email directly, view it on GitHub
<#920 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFOCQ5YBBKQK2URVAV6YJRLY6L7S3AVCNFSM6AAAAABFPPU6D2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRXHAZDANJYGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
@bokuweb I landed here while implemented the following use case => I want to render the component within a Portal and pass as I landed on this PR after some search on the repo issues and PRs, and I can confirm adding However, it doesn't solve my use case. After some research and patching of the library (using |
lastXlastYfor example is relative to the parent anyway. So whats the point of applying this offset to those values?Proposed solution
Tradeoffs
Testing Done