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 a weird stick at top when scrolling bug #376

Merged
merged 1 commit into from
Jan 30, 2017

Conversation

36degrees
Copy link
Contributor

@36degrees 36degrees commented Jan 30, 2017

For reasons unknown, getting the width of the 'stuck' element by calling $el.width() after adding the shim to the document causes Chrome 56 to scroll down by the height of the shim, effectively ‘jumping’ the user down the document. This happens even if you just e.g. call console.log($el.width) without using the returned value.

This behaviour does not occur in other browsers, nor did it occur in Chrome 55.

Somehow, this fixes it.

¯\(ツ)

Before

before

After

after

For reasons unknown, getting the width of the stuck element by calling $el.width() _after_ adding the shim to the document causes Chrome 56 to scroll down by the height of the shim, effectively ‘jumping’ the user down the document.

This behaviour does not occur in other browsers, nor did it occur in Chrome 55.

Somehow, this fixes it.

¯\_(ツ)_/¯
@robinwhittleton
Copy link
Contributor

Calling .width() in jQuery against an element does trigger a reflow, but I’m not sure what that’s triggering the bug. Either way, even without the bug fix this is a microptimisation so let’s get it in.

Are you going to file a Chrome bug?

@robinwhittleton robinwhittleton merged commit 05c5d02 into master Jan 30, 2017
@36degrees
Copy link
Contributor Author

Struggling a little to define what the buggy behaviour actually is. I'm trying to recreate the bug in a codepen but without much luck so far… If I can get a better test case then I will file a bug.

@36degrees 36degrees deleted the fix-weird-stick-at-top-bug branch January 30, 2017 16:56
@NickColley
Copy link
Contributor

Related: alphagov/static#886

@36degrees
Copy link
Contributor Author

@NickColley I looked at using position: sticky with a polyfill, but whilst the native browser behaviour does work perfectly where implemented, none of the existing polyfills worked well for this use case. The main issue is that we only want the sticky behaviour on a > tablet viewport, and none of the polyfills I could find had any consideration for media queries.

@36degrees
Copy link
Contributor Author

@NickColley
Copy link
Contributor

NickColley commented Jan 31, 2017

@36degrees my suggestion is we do not polyfill this since we'll run into issues like this in the future also. It also seems odd to have something that is not guaranteed to be stable in our core toolkit.

36degrees added a commit that referenced this pull request Feb 2, 2017
- Update the alpha, beta and discovery colours to $govuk-blue to match the updated phase banner (PR #370)
- Fix radio button show/hide behaviour when used outside a form (PR #375)
- Fix a "Stick at top when scrolling" component bug related to scroll anchoring in Chrome 56+ (PR #376)
- Minor travis fixes (PR #373)
@36degrees 36degrees mentioned this pull request Feb 2, 2017
36degrees added a commit to alphagov/service-manual-frontend that referenced this pull request Feb 2, 2017
v5.1.1 of GOV.UK Frontend Toolkit includes a fix[1] for a bug in stick-at-top-when-scrolling where the page ‘jumps’ when the in page navigation ‘sticks’[2], introduced by the Scroll Anchoring functionality present in Chrome 56 and above[3].

[1]: alphagov/govuk_frontend_toolkit#376
[2]: http://webarchive.nationalarchives.gov.uk/20161126131022/https://www.gov.uk/service-manual/agile-delivery/agile-government-services-introduction
[3]: https://bugs.chromium.org/p/chromium/issues/detail?id=687118
36degrees added a commit to alphagov/service-manual-frontend that referenced this pull request Feb 2, 2017
v5.1.1 of GOV.UK Frontend Toolkit includes a fix[1] for a bug in stick-at-top-when-scrolling where the page ‘jumps’ when the in page navigation ‘sticks’[2], introduced by the Scroll Anchoring functionality present in Chrome 56 and above[3].

[1]: alphagov/govuk_frontend_toolkit#376
[2]: http://webarchive.nationalarchives.gov.uk/20161126131022/https://www.gov.uk/service-manual/agile-delivery/agile-government-services-introduction
[3]: https://bugs.chromium.org/p/chromium/issues/detail?id=687118
36degrees added a commit to alphagov/service-manual-frontend that referenced this pull request Feb 2, 2017
v5.1.1 of GOV.UK Frontend Toolkit includes a fix[1] for a bug in stick-at-top-when-scrolling where the page ‘jumps’ when the in page navigation ‘sticks’[2], introduced by the Scroll Anchoring functionality present in Chrome 56 and above[3].

[1]: alphagov/govuk_frontend_toolkit#376
[2]: http://webarchive.nationalarchives.gov.uk/20161126131022/https://www.gov.uk/service-manual/agile-delivery/agile-government-services-introduction
[3]: https://bugs.chromium.org/p/chromium/issues/detail?id=687118
gemmaleigh added a commit to alphagov/govuk_elements that referenced this pull request Feb 24, 2017
# 5.1.1

- Update the alpha, beta and discovery colours to $govuk-blue to match
the updated phase banner ([PR
#370](alphagov/govuk_frontend_toolkit#370))
- Fix radio button show/hide behaviour when used outside a form ([PR
#375](alphagov/govuk_frontend_toolkit#375))
- Fix a "Stick at top when scrolling" component bug related to scroll
anchoring in Chrome 56+ ([PR
#376](alphagov/govuk_frontend_toolkit#376))
- Minor travis fixes ([PR
#373](alphagov/govuk_frontend_toolkit#373))

# 5.1.0

- Allow custom options when tracking events ([PR
#365](alphagov/govuk_frontend_toolkit#365))

# 5.0.3

- Change HMRC and DEFRA text colours for improved contrast ([PR
#368](alphagov/govuk_frontend_toolkit#368))
gemmaleigh added a commit to alphagov/govuk-prototype-kit that referenced this pull request Feb 27, 2017
# 5.1.1

- Update the alpha, beta and discovery colours to $govuk-blue to match
the updated phase banner ([PR
#370](alphagov/govuk_frontend_toolkit#370))
- Fix radio button show/hide behaviour when used outside a form ([PR
#375](alphagov/govuk_frontend_toolkit#375))
- Fix a "Stick at top when scrolling" component bug related to scroll
anchoring in Chrome 56+ ([PR
#376](alphagov/govuk_frontend_toolkit#376))
- Minor travis fixes ([PR
#373](alphagov/govuk_frontend_toolkit#373))

# 5.1.0

- Allow custom options when tracking events ([PR
#365](alphagov/govuk_frontend_toolkit#365))

# 5.0.3

- Change HMRC and DEFRA text colours for improved contrast ([PR
#368](alphagov/govuk_frontend_toolkit#368))
paulmsmith pushed a commit to dwp/pyca-prototype that referenced this pull request May 2, 2017
* adds addtional step for users to run npm install post updating via git

* Replace encrypted GitHub token

This updates the environment variable in the config to enable
deployment via Travis CI.

* change node version from 4 to 6

* Setting up a very simple test suite to check the server and build tasks run across nodejs 4, 5 & 6

* make mocha exit properly

* As npm test runs gulp test, remove this from travis.yml

* Simplify the sanity test check

App doesn't need to listen in the test script as supertest accepts the
app variable and handles the listening and un-listening itself.

This also removes the needs for the after block to stop the server.

* moved devdependencies to fix heroku

* Update govuk-elements-sass to 2.2.0

This release includes the custom radio button and checkbox styles.

https://github.com/alphagov/govuk_elements/blob/master/CHANGELOG.md#220

* Update readme to point to docs app

* Remove console log for the file path

This can be seen when viewing the docs app locally.

* v5.0.0

* Update govuk_frontend_toolkit to 5.0.1

https://raw.githubusercontent.com/alphagov/govuk_frontend_toolkit/master
/CHANGELOG.md

# 5.0.1

- Fix role="button" click shim ([PR
#347](alphagov/govuk_frontend_toolkit#347))
- Make font variables lowercase ([PR
#348](alphagov/govuk_frontend_toolkit#348))
- Update selection button documentation ([PR
#350](alphagov/govuk_frontend_toolkit#350))

* Use new font stack reference for unbranded templates

govuk_frontend_toolkit v5.0.1 lowercases the font stack names.

* google analytics

* only add google analytics in promomode

* Move analytics to separate include and use env variable

* Update ‘Back’ link URL

* Bump govuk-elements-sass to 2.2.1

This makes the phase tag in the phase banner $govuk-blue.

As the phase banner is now the same for both alpha and beta banners,
change the phase banner includes to use the recommended class
.phase-banner.

* Set travis to update the latest release branch after deployment

It looks like Travis is deploying the latest-release branch to Heroku.

Let’s move the script that checks for a version tag to after_deploy, in
the hope that it won’t affect the deployment of master to Heroku on a
successful build.

* Fix the "back" link to tutorials and examples

* Bump govuk template to 0.19.2

# 0.19.2

- Increase skiplink colour contrast ([PR
#263](alphagov/govuk_template#263))

# 0.19.1

- Have focus outline appear outside of element rather than covering it
in Safari and Chrome ([PR
#259](alphagov/govuk_template#259))

* Bump standard to current version

And fix reported issues: just spacing.

* Bump toolkit and nunjucks to latest versions

* Remove some unused packages

- consolidate was added to help replace mu2 for mustache rendering
- hogan.js was also in there for mustache rendering

* v5.0.1

- #330 Update GOV.UK toolkit and StandardJS to latest
- #328 Update GOV.UK template to latest
- #324 Fix the example question page’s back link

* use app.locals instead of app.use

* add git step to heroku guide

* Remove full stops from headings

* fix css sourcemaps

* Remove the title attribute

To match the change made to GOV.UK elements: alphagov/govuk_elements#389

* removing links to route.js and update path and file names in branching.html

* Prevent asking users to authenticate twice

This solves the problem with prototypes asking for username/password
twice.

The problem is caused by the ordering in the middleware.

When a user types in the URL for a prototype like
http://govuk-tagging.herokuapp.com they're asked for a
username/password first (via `utils.basicAuth`).

After filling that in they'll be able to "proceed" to the next step,
which redirects them to the `https://` version (via
`utils.forceHttps`).

Because the auth isn't shared between `http` and `https` version, they
are not authenticated anymore and have to enter their username/password
again.

Validated with https://test-prevent-double-auth.herokuapp.com/

* add override service name example

* add comment

* fix docs page

* bump gulp-sass to increase node-sass dependency to enable it to work with node 6 on linux

* add test for docs page

* allow search indexing in promo mode

* v5.1.0

* fix download link

* fix docs links

* Updating gulp-sass to 3.1.0

This is the latest version of gulp-sass.
https://www.npmjs.com/package/gulp-sass

* Bump govuk_frontend_toolkit to 5.1.1

# 5.1.1

- Update the alpha, beta and discovery colours to $govuk-blue to match
the updated phase banner ([PR
#370](alphagov/govuk_frontend_toolkit#370))
- Fix radio button show/hide behaviour when used outside a form ([PR
#375](alphagov/govuk_frontend_toolkit#375))
- Fix a "Stick at top when scrolling" component bug related to scroll
anchoring in Chrome 56+ ([PR
#376](alphagov/govuk_frontend_toolkit#376))
- Minor travis fixes ([PR
#373](alphagov/govuk_frontend_toolkit#373))

# 5.1.0

- Allow custom options when tracking events ([PR
#365](alphagov/govuk_frontend_toolkit#365))

# 5.0.3

- Change HMRC and DEFRA text colours for improved contrast ([PR
#368](alphagov/govuk_frontend_toolkit#368))

* formatting, clarify use of terminal, fix numbering

* Update govuk-elements-sass to 3.0.1

Changelog for GOV.UK elements:
https://github.com/alphagov/govuk_elements/blob/master/CHANGELOG.md

Changelog for the GOV.UK frontend toolkit:
https://github.com/alphagov/govuk_frontend_toolkit/blob/master/CHANGELOG
.md

* Remove DEPRECATED selection-buttons.js

This is no longer required with the radios and checkboxes released in
govuk-elements-sass v3.0.0.

* Update the radio buttons and checkboxes example page

To use the new markup released in GOV.UK elements 3.0.0.

* Replace .block-label with .multiple-choice

Update examples of radio buttons and checkboxes.

Replace ‘.block-label` with `.multiple-choice` as the block-label class
no longer exists.

* Add a .form-section wrapper to examples

Increase the spacing between the radio button and checkbox examples.

* Mention requirement for show-hide-content.js

* Fix radios and checkbox example page

This had nested form elements, which was a mistake. Removing these.

* Add an example of the task list pattern

Add an example of the task list pattern to the docs. Link to it from
the tutorials and examples page.

* Replace em values with gutter variables

Use variables from the govuk_frontend_toolkit’s _measurements.scss file.

Also add a new variable for the spacing to the left of the task list.

* Use the phase tag mixin for the completed status

* Make the "completed" status uppercase

* Rename the task-list to "task-list-page"

* Added config to turn off browser sync

* Add SSH Key for Travis

* Combine scripts and move to a deploy provider

This works in the same way as govuk_elements.

Create a new file - create-release.sh, combining - create release tag
and update release branch, these are deleted.

* Add missing EOF

* To maintain consistency, in this commit I have:
- assigned config.useBrowserSync to a variable
- ran the toLowerCase method on the variable
- change the if statement to reflect the new variable

* add auto data store

* add clear data link to docs app

* only run autodata once, include JS in docs

* use 'data' hash in locals

* use new multiple-choice css, use hyphens in names

* store GET data

* seperate guidance and example pages, added h1s

* refactor checked function

* use list for vehicle features

* fix return to examples link

* refactored docs

* set cookie name and timeout, use crypto

* de-duplicate forceHttps

* Add template pages for content and questions

* Add new template pages to examples index

* v6.0.0

* attempted fix for radio auto stores

* attempted fix for radio auto stores
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.

3 participants