moveable icon indicating copy to clipboard operation
moveable copied to clipboard

Moveable controls not really following mouse cursor when scaling

Open dizayn-design opened this issue 3 years ago • 14 comments

Environments

  • Framework name: React
  • Framework version: 17.0.2
  • Moveable Component version: 0.30.3
  • Testable Address(optional):

Description

When I snatch the control to scale the object, the control doesn't follow the cursor properly. I would expect that the scaling happens that way that the corner of the object (the control) always being at the cursor's position.

moevableScalıng

...
<Moveable
          target={ref.current}
          scalable={true}
          draggable={true}
          onScale={e => (ref.current!).style.transform = e.transform}
          onDrag={e => (ref.current!).style.transform = e.transform}
          renderDirections={['sw', 'nw', 'se', 'ne']}
        />
  <div ref={ref} style={{width: '100px', height: '100px', background: 'red', transform: 'translate(200px, 200px)'}}>
    foo
  </div>
...

dizayn-design avatar Jan 16 '22 21:01 dizayn-design

@dizayn-design

  • moveable 0.28.0
  • react-moveable 0.31.1
  • preact-moveable 0.30.0
  • ngx-moveable 0.24.0
  • svelte-moveable 0.18.0
  • lit-moveable 0.5.0
  • vue-moveable 2.0.0-beta.6
  • vue3-moveable 0.3.0

moveable's new version is released. Check it again.

daybrush avatar Mar 13 '22 17:03 daybrush

react-moveable is now at 0.31.1 but unfortunately the issue remains

dizayn-design avatar Apr 17 '22 12:04 dizayn-design

@dizayn-design

Check react-moveable 0.32.3 version. Thank you :)

daybrush avatar Apr 19 '22 05:04 daybrush

@daybrush sorry for being silent for a month. I'm going to be more active in the project wich depends on moveable. Unfortunaltey even with react-moveable 0.32.7 the problem remains

dizayn-design avatar May 21 '22 18:05 dizayn-design

@dizayn-design

Is it still the same in 0.38.1? I tested it in Firefox right now and it works.

If not, check the Firefox version/Windows or Mac.

daybrush avatar Aug 12 '22 13:08 daybrush

@daybrush I've tested it on firefox 103.0.2 with react-moveable 0.38.2. It is still not resolved unfortunately. It even feels like it got worse.

dizayn-design avatar Aug 16 '22 19:08 dizayn-design

@dizayn-design

"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:103.0) Gecko/20100101 Firefox/103.0"

react-moveable 0.38.2

There is no problem on my computer.

It also works normally on Mac and Windows. What's the difference?

https://codesandbox.io/s/nhyvxt?file=/src/App.tsx

daybrush avatar Aug 17 '22 15:08 daybrush

@daybrush thanks for sharing your sample. Indeed your sample works properly on both firefox and chrome. But as you can see, you're using different attributes on the Moveable component than I do. Is my approach wrong, or is it buggy?

dizayn-design avatar Aug 21 '22 14:08 dizayn-design

@dizayn-design

I'm not sure either.. Can you please provide a demo.

daybrush avatar Aug 23 '22 10:08 daybrush

@daybrush here you go: https://codesandbox.io/s/tender-parm-z42jwf

dizayn-design avatar Aug 24 '22 18:08 dizayn-design

@dizayn-design

Your demo also works well on Windows and Mac.

what is your pc

Also tell me the useragent.

daybrush avatar Aug 24 '22 19:08 daybrush

you mean by "well" that the mouse pointer is always positioned on the nodes during scaling right? This is indeed the case in your demo, but not in mine, at least for me. I use windows. As device, the issue remains on both zbook 15 and vivobook 15 pro.

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

dizayn-design avatar Aug 24 '22 19:08 dizayn-design

@dizayn-design

I understand what you said now.

sorry. I only thought about the size of the cursor.

onScale={(e) => (ref!.style.transform = e.afterTransform)}
onDrag={(e) => (ref!.style.transform = e.transform)}

or scale based on the center.

onScaleStart={e => e.setFixedDirection([0, 0])}
onScale={(e) => (ref!.style.transform = e.afterTransform)}
onDrag={(e) => (ref!.style.transform = e.transform)}

daybrush avatar Aug 24 '22 19:08 daybrush

wow, that first line has fixed it, thanks!

dizayn-design avatar Aug 24 '22 19:08 dizayn-design