Files
notifications-admin/app/assets/stylesheets/components/stick-at-top-when-scrolling.scss
Chris Hill-Scott 84ee8b8327 Stop fixed position elements flying about
Normally, fixed position elements are positioned at `top: 0`.

The code that stops them from overlapping the footer does so by:
- setting the position to absolulte
- setting `top` to a calculated value (eg `1500px`) which makes it sit
  above the footer

The problem is caused because we’re animating `top`, so when scrolling
back up the page elements are getting animated from `1500px` to `0px`,
ie flying up from the bottom of the screen.
2017-06-15 11:47:32 +01:00

36 lines
800 B
SCSS

// CSS adapted from
// https://github.com/alphagov/govuk_frontend_toolkit/blob/d9489a987086471fe30b4b925a81c12cd198c91d/docs/javascript.md#stick-at-top-when-scrolling
.js-stick-at-top-when-scrolling {
overflow: hidden;
margin-left: -$gutter-half;
margin-top: -10px;
margin-bottom: 5px;
padding: 10px 0 0 $gutter-half;
position: relative;
top: 5px;
transition: top 0.1s ease-out, box-shadow 1s ease-in-out;
.form-group {
margin-bottom: 20px;
}
}
.content-fixed {
position: fixed;
top: 0;
background: $white;
z-index: 100;
margin-top: 0;
padding-right: $gutter-half;
border-bottom: 1px solid $border-colour;
box-shadow: 0 2px 0 0 rgba($border-colour, 0.2);
transition: background 0.6s ease-in-out, margin-top 0.4s ease-out;
}
.shim {
display: block;
}