Skip to content

Commit

Permalink
Fix CSS media query
Browse files Browse the repository at this point in the history
Landscape changes would be applied even if it wasn't displayed on a smaller screen
  • Loading branch information
nfoert committed Oct 15, 2024
1 parent ca3d508 commit 4e56c4d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
18 changes: 0 additions & 18 deletions cardie/main/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,4 @@
};
}
</script>
<!-- Script for disable scrollSnap on landscape mode -->
<script>
function disableScrollSnapping() {
if (window.matchMedia("(orientation: landscape)").matches) {
document.documentElement.style.scrollSnapType = "none";
document.documentElement.style.scrollSnapPointsY = "none";
} else {
document.documentElement.style.scrollSnapType = "y mandatory";
document.documentElement.style.scrollSnapPointsY = "repeat(100vh)";
}
}

// Call the function once to ensure it runs on load
disableScrollSnapping();

// Re-run the function on orientation change
window.addEventListener("orientationchange", disableScrollSnapping);
</script>
{% endblock %}
4 changes: 2 additions & 2 deletions cardie/static/main/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ body, html {

}

@media (max-width: 1000px) {
@media (max-width: 1000px) {
/* Small Screens */

#home_card {
Expand Down Expand Up @@ -214,7 +214,7 @@ body, html {

/* Properties for landscape mode */

@media only screen and (orientation: landscape) {
@media (orientation: landscape) and (max-width: 1000px) {

body, html {
scroll-snap-type: none;
Expand Down

0 comments on commit 4e56c4d

Please sign in to comment.