Moveable: Using onResize and updateRect leads to unexpected behavior

Created on 19 Nov 2019  路  8Comments  路  Source: daybrush/moveable

If the element changes are not related to the onResize event, the calculations of onResize event become mistaken.
Example of this behavior:
https://codesandbox.io/s/resize-updaterect-vuujb

How to fix such an issue?

bug complete question

All 8 comments

@qvantor

The target is changed by width and height.
What is the reason for switching to child's clientHeight?

Or do you want to use delta?
https://daybrush.com/moveable/release/latest/doc/Moveable.html#.OnResize

@daybrush In the case above, there is not enough space for the text, after reducing the width. For this reason, the text is transferred to the next line - the block height grows and this change in block height leads to incorrect calculations.

@qvantor

moveable 0.10.8 is released. check it with following code:

  const moveable = new Moveable(document.body, {
    target: text,
    resizable: true,
    origin: false,
    renderDirections: ["w", "e"]
  }).on("resize", ({ target, width, drag }) => {
    target.style.width = `${width}px`;

    // get drag event
    target.style.transform = `translate(${drag.beforeTranslate[0]}px, ${
      drag.beforeTranslate[1]
    }px)`;
  });

thank you :)

@daybrush It's awesome!
23 hours and it's done!
Thank you very much!

@daybrush
one more thing - element flying around when resizing, while keepRatio: false

Example:
https://codesandbox.io/s/resize-updaterect-updated-rg9tg
Steps to reproduce:
1) Rotate element
2) Resize element

@daybrush also onResize event height don't equal to .getRect() method height

@qvantor

moveable 0.11.0 is released. Also Use getRect() method's offsetHeight.

Test:
https://codesandbox.io/s/resize-updaterect-updated-eb1bb

Thank you :)

@daybrush thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

plotpoi picture plotpoi  路  4Comments

adityakrshnn picture adityakrshnn  路  4Comments

adityakrshnn picture adityakrshnn  路  6Comments

tesmem101 picture tesmem101  路  3Comments

prasanthLalapeta picture prasanthLalapeta  路  4Comments