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

fix(transition-ios): RTL fix for transition on ios #11820

Merged
merged 4 commits into from
Jun 5, 2017

Conversation

sijav
Copy link
Contributor

@sijav sijav commented May 28, 2017

Short description of what this resolves:

This will fix the transition on ios platform when it's RTL

Changes proposed in this pull request:

  • Changed the translateX animations with opposite value if it's on rtl

Ionic Version: 2.x / 3.x

Fixes: #11211

@AmitMY
Copy link
Contributor

AmitMY commented May 28, 2017

Works very well!
I am not very sure about the naming though, as OFF_LEFT_RTL seems to really mean the offset to the right.

Do you think using start and end makes sense for this? like OFF_START, OFF_END, OFF_START_RTL, OFF_END_RTL? (left is start, right is end)

@sijav sijav force-pushed the rtl-fix-transition-ios branch from 1bde6d4 to c6fa3d4 Compare May 28, 2017 06:08
@sijav
Copy link
Contributor Author

sijav commented May 28, 2017

@AmitMY nevermind what I was saying earlier :D it was the worst idea, besides it really is right offset not start offset, but we do it -99.5% instead of 99.5%

@AmitMY
Copy link
Contributor

AmitMY commented May 28, 2017

@sijav Yeah I saw.. I was just about to comment the -- case, but you reverted :)
Keeping it right & left seems reasonable (as two separate cases).
There is a solution to do with only one set of variables, but I am not sure the overhead is worth it.
(have a utility function that gets a number/string, casts it into a string, then checks if the first character is -, and if so removes it, otherwise adds it)

@sijav
Copy link
Contributor Author

sijav commented May 28, 2017

@AmitMY yeah ... it was a very bad solution :D
I don't think it worth it but let me know if anything could be done...

@brandyscarney
Copy link
Member

Thanks for the PR! This looks good to me. I want to get one more team member to test it and if it looks good to them we'll merge it. 😄

@AmitMY
Copy link
Contributor

AmitMY commented Jun 4, 2017

Khalid had a good point. Instead of duplicating the variables, you can do:
OFF_LEFT = this.plt.isRTL ? "-33%" : "33%"

So you only check once (per call) and it is cleaner.

What do u think?

@sijav
Copy link
Contributor Author

sijav commented Jun 4, 2017

@AmitMY Khalid? I don't see any comment from him, but nevertheless I have nothing against it however I don't know how RTL change can work in runtime but I hope this change won't affect it.

@AmitMY
Copy link
Contributor

AmitMY commented Jun 4, 2017

@sijav Well, of course that part of it will be to move the constants to the init function (which is also required for the this.plt.isRTL), which I think will mean that change will work (if it works for current code)
Your code works, and is good, it is just those double variables that are tiny bit annoying :) brandy just looks for more reviews to merge it, hopefully soon.

Khalid commented but removed his comment.

@Khalid-Nowaf
Copy link

Sorry guys, I just removed my comment after seen my suggestion is already suggested by @AmitMY.

@sijav
Copy link
Contributor Author

sijav commented Jun 5, 2017

@AmitMY How can I do that?
The OFF_LEFT is a const variable which means we need to declare it's value when we declare the variable and we cannot change it afterward (eg. on init of the class), and where we declare it is on the root of the ts not on any class, and it will be called at the init of the program (when the program is about to run the js), so there's no this.plt available.
EDIT: the only way I can do this is with this code const OFF_LEFT = document.getElementsByTagName('html')[0].getAttribute('dir') == 'rtl' ? "-33%" : "33%" which frankly I can't see any reason why I should do this :|

@AmitMY
Copy link
Contributor

AmitMY commented Jun 5, 2017

@sijav Haha no not like that :P
Put the constants inside the init method instead of outside, so it will have the same behavior, and there will not be duplication.
+
It will work if you change direction in run time, iff the current fix works in runtime

@@ -20,6 +18,8 @@ export class IOSTransition extends PageTransition {
super.init();

const plt = this.plt;
const OFF_RIGHT = plt.isRTL ? '-99.5%' : '99.5%';
const OFF_LEFT = plt.isRTL ? '33%' : '-33%';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better! @brandyscarney any other note or can this get merged?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I have someone else testing it today and if all goes well with their tests I will merge it. 🙂

@mhartington
Copy link
Contributor

Only thing I can see is that the swipe to go back gesture isn't moving the active page, but that issue existed before this PR, so I think it's ok for now.

@sijav
Copy link
Contributor Author

sijav commented Jun 5, 2017

@mhartington I've made about a dozen PR #11822 will fix that

@brandyscarney brandyscarney merged commit 6322134 into ionic-team:master Jun 5, 2017
@brandyscarney
Copy link
Member

Perfect, thanks!

@sijav sijav deleted the rtl-fix-transition-ios branch June 5, 2017 18:38
AmitMY pushed a commit to AmitMY/ionic that referenced this pull request Jun 6, 2017
* fix(transition-ios): RTL fix for ios transition

* put const variables in init of page transition and remove RTL specific variables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants