-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add rotation function #370
base: master
Are you sure you want to change the base?
Conversation
+ add event listeners but only return instance at this point in time + add rotate animation to demo
Sorry for delayed response.
If you could update the PR with these details/changes - it will speed up merging this pull request. Otherwise I'll try to find some time during this weekend to go through these changes. Thanks again for your work! |
I'll try to expand the readme tonight.
|
First of all, thank you for the MR and great work @shadowjustice. I'm having issues with my rotation not happening around the center of the viewport. I'm drawing a map from somewhat scattered xml-data but setting the parameters fit and center, makes it work. But when rotating, my map rotates away from the area instead of staying centered. I've tried setting Do you have any idea? |
Hi Indeed atm the rotation is not around the center. I am going to check on how to set a point around which the svg rotates. |
@deeankmet I have researched it for a bit and realised the following. For rotation to happen we add rotate So if you have a rectangle 50x50 the centerpoint is 25x25 so So my suspicion is that those x and y aren't correct in your case. Which I do not fully understand then because the height and width are the height and width from your viewport. Anyways rotating around something differnt then the centerpoint could be seen as an improvement but secondary in my opinion. First getting this PR done. |
Added some tests there is 1 strange occurance see comment at test resetRotate() Tested rotation in * chrome * firefox * edge Too tired now to install the other browsers.
This probably happens because the image is panned, but the rotate works from the middle. If that's the case then the centre of what user sees is not the same as the centre of current rotation, and the image is moved away. That's why for |
That seems indeed the reason. Then maybe we should make the center point variable. Actually it should be variable. I’ll try and add it. |
Thanks for the research @shadowjustice and @bumbu. That makes sense. I've solved my issue by adding all my drawn elements to a group, then centrering the entire group on origo which makes the rotation work perfectly independent of the data I used. Thanks again. |
I haven't been able to expand this. Any toughts on current commits? |
@shadowjustice sorry for the delay.
This last point is kind of a deal breaker, and I'm not sure what to do about it. |
Hi, I had to reset my pc and work has been piling on. Does your wip contain an example for the bug in chrome? I have been thinking about this change and for the main part while now I do |
The bug is reproducible both in my stack, and in this PR. You can see that the If we could rotate using matrix transform, that would solve the issue and unblock this PR from being merged. |
Okay before my changes we had a SVG transform attribute AND a style transform attribute filled in: So in my original code (not the reworked from @bumbu. Animation still works. Except for the fact that no css style attribute is present anymore: For some reason after applying the changes from @bumbu (which in a sense are definitely good changes) the style property appears again but this time while it is present it does not update. The reason for not updating has now been found and are more or less just problems with formatting and differences between svg transform and css transform. I quote svg transform doc
Anyhow I come with the following question. I think this is a problem in itself. The problem would be solved if we only use the svg transform since that one also has rotation around a certain point built in.. If we would use css transform then we need to make use of transform-origin to make rotations around center points possible. Since I'm not sure how to put a stash on github Thoughts you guys have? In my current version I have converted the matrix back to the seperate actions => scale, translate,... and separated the built up transform for css and svg. I have a working set. Since I am not sure how to upload a stash to github in attachment the diff |
Thanks for the pull request, and I apologize for my lack of response. My job has shifted away from front end, so I unfortunately can't keep up with maintenance. Would you be interested in becoming a maintainer? |
This new pull request instead of #169 which is outdated and has merge conflicts.