Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Last active May 2, 2018 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolanlawson/a9c5c1d05b7996ca4b9143a7808de50d to your computer and use it in GitHub Desktop.
Save nolanlawson/a9c5c1d05b7996ca4b9143a7808de50d to your computer and use it in GitHub Desktop.
Sticky element flicker demo
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<style>
.compose-box-fade-in {
transition: opacity .2s linear;
}
.compose-box-button-wrapper {
width: -moz-fit-content;
width: fit-content;
margin-left: auto;
display: flex;
justify-content: flex-end;
}
.compose-box-button-wrapper.compose-button-sticky {
position: -webkit-sticky;
position: sticky;
top: 10px;
z-index: 2;
}
.timeline-home-anchor-container,
.timeline-home-page {
position: relative;
}
main {
position: relative;
width: 602px;
max-width: 100vw;
padding: 0;
box-sizing: border-box;
margin: 30px auto 15px;
background: #fff;
border: 1px solid #dadada;
border-radius: 1px;
min-height: 70vh;
}
.container {
overflow-y: auto;
overflow-x: hidden;
-webkit-overflow-scrolling: touch;
will-change: transform;
position: absolute;
top: 42px;
left: 0px;
right: 0px;
bottom: 0px;
}
*:focus {
/* remove this and the flicker goes away */
outline: 2px solid #c5d1f6;
}
body {
margin: 0;
font-family: system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
font-size: 14px;
line-height: 1.4;
color: #333;
background: #e8edfb;
-webkit-tap-highlight-color: transparent;
}
.compose-box-button-halo {
border-radius: 2px;
margin: 5px 15px 15px 5px;
background: rgba(255, 255, 255, 0.1);
pointer-events: auto;
}
button {
font-size: 1.2em;
background: #e6e6e6;
border-radius: 2px;
padding: 10px 15px;
border: 1px solid #a7a7a7;
cursor: pointer;
color: #333;
}
.compose-box-button {
grid-area: k;
justify-self: right;
text-transform: uppercase;
position: relative;
margin: 5px;
pointer-events: auto;
}
button.primary {
border: 1px solid #132c76;
background: #6081e6;
color: #fff;
}
.timeline {
height: 2000px;
width: 100%;
}
</style>
</head>
<body>
<div id="sapper">
<div tabindex="0" class="container">
<main>
<div class="timeline-home-page" aria-busy="false">
<div class="compose-box-button-wrapper compose-button-sticky compose-box-fade-in">
<div class="compose-box-button-halo">
<button class="primary compose-box-button" aria-label="Compose">
<span>SCROLL AND WATCH ME FLICKER</span>
</button>
</div>
</div>
<div class="timeline"></div>
</div>
</main>
</div>
</div>
<script>
window.onload = () => document.querySelector('.container').focus()
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment