Skip to content
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: setAngle() method #502

Merged
merged 1 commit into from
Jan 2, 2020
Merged

ADD: setAngle() method #502

merged 1 commit into from
Jan 2, 2020

Conversation

VladimirMikulic
Copy link
Contributor

@VladimirMikulic VladimirMikulic commented Dec 27, 2019

The method accepts an angle in degrees and sets element's rotation to be
that angle. It can also accept negative degrees.

Demo

Resolves #102

@sashadev-sky @jywarren @SidharthBansal could you review this, please?

The method accepts an angle in degrees and sets element's rotation to be
that angle.

Resolves #102
@jywarren
Copy link
Member

jywarren commented Jan 2, 2020

This is awesome. Would you be interested in making a simple test for this? Thank you!

@VladimirMikulic
Copy link
Contributor Author

VladimirMikulic commented Jan 2, 2020

@jywarren this cannot be tested because getAngle() method uses L.DomUtil.getStyles function which is undefined(not accessible) in tests. I could refactor getAngle() and then add tests in separate PR.

Can we get this feature merged?
Thanks.

@jywarren
Copy link
Member

jywarren commented Jan 2, 2020

Sure, we'll go ahead and merge this then; it's an addition rather than a change in any case. Would you be able to open a new issue describing what'd have to happen to get a test for this? Thank you!

@jywarren jywarren merged commit ab3eccc into publiclab:main Jan 2, 2020
@VladimirMikulic
Copy link
Contributor Author

VladimirMikulic commented Jan 2, 2020

@jywarren thanks! I could open the issue, that's not the problem, but the problem is in tests.
In browser getAngle works flawlessly, but in the tests, it always returns 0.
It might be related to the fact that we use PhantomJS instead of a "real" browser.

We'll need to debug this issue before we could write a test for setAngle and getAngle.

@jywarren
Copy link
Member

jywarren commented Jan 2, 2020 via email

@VladimirMikulic
Copy link
Contributor Author

VladimirMikulic commented Jan 2, 2020

@jywarren I have some news for you.
I was right, it was an issue with PhantomJS, L.DomUtil.getStyles is accessible in ChromeHeadless but inaccessible in PhantomJS. On the other hand, 3 tests fail on ChromeHeadless.

I've noticed that rotation property is correct although getAngle returns 0.
Maybe our test could be:

describe('#setAngle', function() {
    it('should set image angle to 90 deg', function () {
      overlay.setAngle(90)
      expect(overlay.rotation).to.equal(-90);
    });
  });

This would require fixing 3 failing tests, and switching to ChromeHeadless.
Also, PhantomJS is not active anymore.
What do you think? Thanks.

@jywarren
Copy link
Member

jywarren commented Jan 3, 2020 via email

@VladimirMikulic
Copy link
Contributor Author

Yes, I am participating in GCI and we could make GCI task out of this.
Could you also please provide your opinion on publiclab/plots2#7086.
It's form validation, very important :)

Thanks.

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 3, 2020 via email

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 3, 2020 via email

@VladimirMikulic
Copy link
Contributor Author

Thanks @SidharthBansal, I've noticed that you approved the task on GCI dashboard.
Did you see my comments in the PR?
Could you tell what you think?

Thanks.

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 3, 2020 via email

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 3, 2020 via email

@sashadev-sky
Copy link
Member

@VladimirMikulic this is so great!!
Also I know that the Leaflet js library still uses phantomJS so i'm not sure we need an update unless you really want to make a case for it.
And sounds good for the rotation property. I'll open a new Github issue for that now and upload it to the GCI dashboard!

@sashadev-sky
Copy link
Member

actually wait, the rotation property does not work correctly! I will update it to use your getAngle method. For the tests then we'd have to sort of polyfill L.DomUtil.getStyle? Anyway for GCI credit this is complete so don't worry about it for now

@VladimirMikulic
Copy link
Contributor Author

@sashadev-sky we can either polyfill L.DomUtil.getStyle or switch to ChromeHeadless.

@sashadev-sky
Copy link
Member

@VladimirMikulic I could be misunderstanding the problem you are running into but I think the issue might be that the css transform property throws the error, not the method, and it can be fixed by updating the code to var matrix = this._image.style[L.DomUtil.TRANSFORM]. Lmk!

@VladimirMikulic
Copy link
Contributor Author

VladimirMikulic commented Jan 10, 2020

@sashadev-sky yes, this._image.style[L.DomUtil.TRANSFORM] doesn't throw errors in the test, but the returned angle from getAngle is still 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get rotate angle of image layer
4 participants