moveable icon indicating copy to clipboard operation
moveable copied to clipboard

Question: Moveable resize event how to calculate the target top and left ?

Open chenp1204 opened this issue 3 years ago • 2 comments

Environments

  • Framework name: Vue
  • Framework version: 2.6.13
  • Moveable Component version: 0.27.2
  • Testable Address(optional):

Description

Hi @daybrush , when i resize the target, the demo use css tanslate change the target position,

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

but i want to get the target top and left to change position how can i calculate the top and left according to resize event params?

chenp1204 avatar Nov 29 '21 03:11 chenp1204

@chenp1204 The drag property has top left information.

const width = e.width;
const height = e.height;
const top = e.drag.top;
const left = e.drag.left;

e.target.style.cssText += `width: ${width}px; height: ${height}px; left: ${left}px; top: ${top}px`;

daybrush avatar Nov 29 '21 14:11 daybrush

Would be great if this would become part of the "How to use" example of the Readme.

jvolker avatar May 19 '22 16:05 jvolker