I tested it on different up-to-date browsers, therefore it can't be compatibility problem. I'm using create-react-app with styled components, here's my code:
import React, { Component } from 'react';
import styled, { createGlobalStyle } from 'styled-components';
const GlobalStyle = createGlobalStyle`
@import url('https://fonts.googleapis.com/css?family=Merriweather|Oleo+Script');
`
const Wrapper = styled.div`
scroll-snap-type: y mandatory;
display: flex;
flex-direction: column;
font-size: 16px;
`
const Home = styled.div`
scroll-snap-align: center;
height: 100vh;
background-color: yellow;
display: flex;
flex-direction: row;
`
const Menu = styled.div`
scroll-snap-align: center;
height: 100vh;
background-color: blue;
display: grid;
`
const Speciality = styled.div`
scroll-snap-align: center;
height: 100vh;
background-color: green;
`
class App extends Component {
render() {
return (
<Wrapper>
<GlobalStyle />
<Home />
<Menu />
<Speciality />
</Wrapper>
);
}
}
export default App;
It doesn't do anything when I'm scrolling, I've tried almost anything. It won't work without styled-components either.
EDIT: I copied my code to codesandbox: https://codesandbox.io/s/72jmn1p1w1
I had some problems with the
scroll-snap
too.For me this doesn't work without the
overflow-y: scroll
, try to put this on your Wrapper.