Browse Source

js recharge page projets filtrés au niveau des filtres

ouidade 11 tháng trước cách đây
mục cha
commit
5c941c4654

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
web/themes/custom/eql/dist/assets/bundle.js


+ 3 - 0
web/themes/custom/eql/dist/assets/css/bundle.css

@@ -3978,6 +3978,9 @@ svg.ext {
 .path-projets .region-content #block-contenudelapageprincipale .layout--onecol .block-region-content .block-views-blockprojets-block-1 .view-projets {
   margin: auto;
 }
+.path-projets .region-content #block-contenudelapageprincipale .layout--onecol .block-region-content .block-views-blockprojets-block-1 .view-projets #filtres {
+  scroll-margin-top: 10rem;
+}
 .path-projets .region-content #block-contenudelapageprincipale .layout--onecol .block-region-content .block-views-blockprojets-block-1 .view-projets .view-filters {
   margin-top: 4rem;
   display: flex;

+ 23 - 0
web/themes/custom/eql/scripts/main.js

@@ -279,6 +279,29 @@ document.querySelectorAll('a[href^="http"]').forEach(link => {
 
 /////////////// end ouverture liens externes vers nouvel onglet //////////////////
 
+document.addEventListener("DOMContentLoaded", function () {
+  const form = document.querySelector(".views-exposed-form");
+
+  // console.log(form);
+
+  if (form) {
+    form.setAttribute("action", form.action.split("#")[0] + "#filtres");
+  }
+  if (window.location.hash === "#filtres") {
+    const target = document.getElementById("filtres");
+    if (target) {
+      // target.scrollIntoView({ behavior: "smooth", block: "start" });
+      const offset = 300;
+      const top = target.getBoundingClientRect().top + window.pageYOffset - offset;
+
+      window.scrollTo({
+        top: top,
+        behavior: "smooth"
+      });
+    }
+  }
+
+});
 
 })(jQuery, window);
 

+ 3 - 0
web/themes/custom/eql/scss/pages/_lesprojets.scss

@@ -121,6 +121,9 @@
                                 margin: auto;
 
                                 //filtres
+                                #filtres {
+                                    scroll-margin-top: 10rem; 
+                                  }
                                 .view-filters{
                                     margin-top: 4rem;
                                     display: flex;

+ 1 - 1
web/themes/custom/eql/templates/views-view.html.twig

@@ -52,7 +52,7 @@
     </div>
   {% endif %}
   {% if exposed %}
-    <div class="view-filters">
+    <div class="view-filters" id='filtres'>
       {{ exposed }}
     </div>
   {% endif %}

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác