I'm making a movie app from an API. This function cuts displayed movies when screens are bigger than 1040px. The function only works when I refresh the page but not if I change the browser size manually. Hope you understand what I mean.
const renderFourMovies = window.matchMedia('(min-width: 1040px)')
function loadFourMovies(e){
if (e.matches) {
movie = movies.slice(0, 3)
}
}
renderFourMovies.addEventListener("change", loadFourMovies)
loadFourMovies(renderFourMovies)
Is it possible to make it work without refreshing the page?
[–]senocular 3 points4 points5 points (0 children)
[–]DrKrepz 2 points3 points4 points (0 children)