angular2-draggable icon indicating copy to clipboard operation
angular2-draggable copied to clipboard

Problems when scale transform applied to parent

Open fredGitelman opened this issue 7 years ago • 9 comments

This is my first ever issue-report. Sorry if it is not appropriate for whatever reason.

As far as I can tell, If any ancestor of the div you are trying to drag has a CSS scale transform, things don't work very well (at least on Chrome on Mac - have not tested elsewhere).

It is kind of hard to describe the exact symptoms - there are different problems depending on if you scale up or scale down both for simple dragging and for bounds-checking.

These problems are easy to replicate using dev tools on your demo and editing CSS to include (say) transform: scale(.75) or (say) transform: scale(1.5).

Thanks for ngDraggable!

fredGitelman avatar Dec 30 '17 01:12 fredGitelman

Thanks for reporting this issue. It indeed overwrites the transform style. Need to fix.

xieziyu avatar Jan 04 '18 14:01 xieziyu

Fixed in v1.1.0: Please set [scale] option to fix this issue.

xieziyu avatar Feb 01 '18 08:02 xieziyu

@xieziyu [scale] option is not working - it is creating more issue I believe the PR generated by @Daithi1 is stable and working fine.

If possible can you please validate that PR or please elaborate the issues so that we can take look further...

paresh-2016 avatar Nov 28 '18 05:11 paresh-2016

@paresh-2016 Please provide more details about [scale] option issue.

Daithi1's PR failed the test when [inBounds] and [boundary] set. The dragging element hit the boundary and bounced off.

xieziyu avatar Nov 28 '18 05:11 xieziyu

@xieziyu even after using the [scale] option the issue remains where if there is a CSS transform scale applied on the parent of the element we want to drag, the cursor and the element become de-synced.

So it seems like we need to divide the translateX and translateY in the transform() function by the scale

rathodsanjay avatar Nov 28 '18 05:11 rathodsanjay

@rathodsanjay Thank you. I've published new version with your fix.

xieziyu avatar Nov 29 '18 02:11 xieziyu

@xieziyu Thanks!

rathodsanjay avatar Nov 29 '18 04:11 rathodsanjay

@xieziyu - I have made a minor enhancement to the above changes, to prevent the component from changing its position on initial click when css scale is applied to the parent element. I have raised a PR for the same - #134

rathodsanjay avatar Dec 24 '18 04:12 rathodsanjay

There is one more problem. When you have set scale != 1 (e.q. 0.6) and your div already exist, everything works prefect. The problem occurs, when you try to assign new value to [position] when div is already created and [sclae] is set. The output position is different then expected. The scale value is not used while setting new position value by user.

InYourHead avatar Feb 21 '19 08:02 InYourHead