Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/forestryio/hugo-theme-novela.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormountainbug95 <tannersmithtn95@gmail.com>2019-09-27 23:15:49 +0300
committermountainbug95 <tannersmithtn95@gmail.com>2019-09-27 23:15:49 +0300
commit87d529d3ced832c198e9e83ec8ab081dbeeca28c (patch)
tree8a8e32e2ea412cbda98199f26f975de591cf4dce
parentf757b26902d5500507160ae890a53b8f76766839 (diff)
Add extra mobile support for the list layout
-rw-r--r--assets/js/toggleLayout.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/assets/js/toggleLayout.js b/assets/js/toggleLayout.js
index 28bd9d6..14f8da2 100644
--- a/assets/js/toggleLayout.js
+++ b/assets/js/toggleLayout.js
@@ -1,10 +1,26 @@
document.getElementById("btnGrid").addEventListener("click", makeGrid);
document.getElementById("btnRows").addEventListener("click", makeRows);
+window.addEventListener("resize", adjustListAtMobile);
+
+let listRemoveWidth = window.matchMedia("(max-width: 735px)");
+let listAddWidth = window.matchMedia("(min-width: 735px)");
+let isList = false;
+
+function adjustListAtMobile(){
+ if (listRemoveWidth.matches) {
+ document.getElementById("articlesList").classList.remove("articles-list-container-alt");
+ }
+ else if (listAddWidth.matches && isList === true) {
+ document.getElementById("articlesList").classList.add("articles-list-container-alt");
+ }
+}
function makeGrid(){
document.getElementById("articlesList").classList.remove("articles-list-container-alt");
+ isList = false;
}
function makeRows(){
document.getElementById("articlesList").classList.add("articles-list-container-alt");
+ isList = true;
} \ No newline at end of file