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 reveal enableScroll calculation of scrollTop #10786

Merged
merged 3 commits into from Jan 24, 2018

Conversation

SassNinja
Copy link
Contributor

This PR fixes an issue with the scrollTop calculation of the _enableScroll method in the reveal component.
Precisely the issue occurred for me on iOS / iPhone.

After some debugging I found out the line parseInt($("html").css("top")) doesn't work as expected in this scenario because the class .is-reveal-open got removed before.
Therefore the html element got position:static again an returns auto as top-value on iOS.

To fix this I've moved the scrollTop calculation from the disabledScroll/enableScroll methods to the place they get called and pipe them through as param.
So now the top value gets calculated before .is-reveal-open is removed.

@IamManchanda @kball would you review?

The target scrollTop must be calculated BEFORE the is-reveal-open class gets removed.
Otherwise iOS is not able to determine the correct top value but uses "auto".
To add a scrollTop param to the disableScroll is not necessary but due to consistency I've done it here the same way.
@@ -406,7 +410,7 @@ class Reveal extends Plugin {

_this.$element.attr('aria-hidden', true);

_this._enableScroll();
_this._enableScroll(scrollTop);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we move enableScroll before removing is-reveal-open, instead of passing the scrollTop ? I think this would be cleaner, but I don't know the codebase enough to be sure this would not cause others bugs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I first tried this way and it fixed the iOS issue (original scrollTop restored after having closed the reveal).
But unfortunately non-iOS / desktop has got the issue then!

The reason is that the class is-reveal-open adds fixed position to the html and thus the scrollTop restoration don't work before removing that class.

My solution was the only way I've found to get rid of the issue for all cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ncoden what do you think?

Would be great to see this iOS issue be gone in my projects (without adjusting the sources temporary)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the late reply. I'll check if it can be cleaner, then merge this.

@ncoden ncoden added this to the 6.4.4 milestone Jan 17, 2018
… in Reveal

Try to keep a more or less enclosed behavior by using defaults properties. The functions behaviors can be changed when needed.
@ncoden
Copy link
Contributor

ncoden commented Jan 20, 2018

@SassNinja I think it is clean enough now. You you check if this works in your project ? I have some trouble to reproduce the issue.

@SassNinja
Copy link
Contributor Author

Yup @ncoden it's still working for me.
While testing I've noticed the issue occurs on iOS 9.3 for me but not on iOS 11.2 anymore.
Nevertheless I think it's a good idea to fix it with this PR.

@ncoden ncoden merged commit 4f0fec4 into foundation:develop Jan 24, 2018
@SassNinja SassNinja deleted the fix-reveal-enable-scroll branch January 25, 2018 08:06
ncoden added a commit to ncoden/foundation-sites that referenced this pull request Jun 16, 2018
…roll for v6.5.0

7e67525 Fix reveal enableScroll calculation of scrollTop
4f27733 refactor: add defaults to `_enableScroll`/`_disableScroll` properties in Reveal
808fc3b style: document the foundation#10786 bug in Reveal

Co-Authored-By: Nicolas Coden <nicolas@ncoden.fr>
Signed-off-by: Nicolas Coden <nicolas@ncoden.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants