'scroll-snap won't scroll smoothly in Firefox
I have a simple page using 100vh blocks that on scroll I want to 'snap' to the next block.
This works using scroll-snap in Chrome & Safari (OS Mac) but not in Firefox. In Firefox the page scrolls but stops abruptly - so is very stop/start. Not sure about Edge/IE11 at this point (untested).
Example included in post of my current markup/CSS.
Unsure what is wrong or if this is a common issue with Firefox - or maybe I need a polyfill or JS solution to be more robust? Would appreciate some help, hopefully it's not a big issue - thanks!
/**
* Base.
*/
::-moz-selection {
background-color: black;
color: white;
}
::selection {
background-color: black;
color: white;
}
html {
background: white;
font-size: 62.5%;
height: 100vh;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-overflow-scrolling: touch;
-webkit-tap-highlight-color: $white;
-webkit-text-size-adjust: 100%;
}
body {
animation: fadein .24s .72s forwards;
background-color: transparent;
color: black;
font-variant-ligatures: common-ligatures discretionary-ligatures historical-ligatures;
font-family: "Helvetica Neue", Helvetica, sans-serif;
font-size: 2.4rem;
font-weight: 700;
height: 100vh;
line-height: 1.2;
opacity: 0;
margin: 0;
padding: 0;
text-rendering: optimizeLegibility;
}
/**
* Elements.
*/
img {
display: block;
margin: 0 auto;
width: 100%;
max-width: 1200px;
}
p {
margin: 0 auto;
padding: 0;
max-width: 1200px;
}
a,
a:visited {
background-image: linear-gradient(to right, black 33.33333%, transparent 33.33333% 66.66666%, black 66.66666%);
background-position: right bottom;
background-repeat: no-repeat;
background-size: 300% 8%;
color: black;
padding-bottom: 4px;
text-decoration: none;
}
a:focus,
a:hover {
background-position: left bottom;
color: black;
text-decoration: none;
transition: background-position .4s ease-in;
}
/**
* Sections.
*/
.page {
height: 100vh;
}
.shopify-section {
display: flex;
flex-flow: column nowrap;
height: 100vh;
overflow: auto;
scroll-snap-type: y mandatory;
}
.section {
background: white;
box-sizing: border-box;
display: flex;
align-items: center;
min-height: 100vh;
padding: 24px;
scroll-snap-align: start;
}
/**
* Mouse Scroll.
*/
.mouse {
background: white;
border: 3px solid black;
border-radius: 16px;
height: 40px;
margin-left: -12px;
position: absolute;
bottom: 24px;
left: 50%;
overflow: hidden;
width: 24px;
z-index: 0;
}
.mouse:before { /* Dot */
animation: scroll .8s cubic-bezier(.7,0,.3,1) infinite alternate;
background: black;
border-radius: 100%;
content: "";
height: 4px;
margin-left: -2px;
position: absolute;
top: 8px;
left: 50%;
width: 4px;
z-index: 2;
}
.mouse:after { /* Shadow */
animation: scroll .8s cubic-bezier(.7,0,.3,1) infinite alternate;
animation-delay: 80ms;
background: #ccc;
border-radius: 4px;
content: "";
height: 4px;
margin-left: -2px;
position: absolute;
top: 8px;
left: 50%;
width: 4px;
z-index: 1;
}
/**
* Media Queries.
*/
@media only screen and (min-width: 800px) {
body {
font-size: 3.6rem;
}
}
/**
* Animations.
*/
@keyframes fadein {
0% { opacity: 0; }
100% { opacity: 1; }
}
@keyframes scroll {
0% { transform:translateY(0); }
100% { transform:translateY(14px); }
}
<div class="mouse"></div>
<div class="page">
<div class="shopify-section">
<div class="section">
<p>1. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div class="section">
<p>2. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
<div class="section">
<p>3. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
