adding logic to the enews slideout so that it only opens on first visit
authorAnthony Talarico <talarico@gaslightmedia.com>
Wed, 10 Apr 2019 19:56:10 +0000 (15:56 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Wed, 10 Apr 2019 19:56:10 +0000 (15:56 -0400)
parts/enews-sticky.php

index 9e02114..1db0c32 100644 (file)
 </div>
 <script>
     jQuery(function($){
+        var firstLoad = localStorage.getItem("firstLoad");
         $(document).on("click", ".enews-handle", function(){
             $("#glm-enews-sticky").toggleClass("enews-slideout");
         });
-        if (window.matchMedia("(min-width: 641px)").matches) {
+        console.log(firstLoad)
+        if (window.matchMedia("(min-width: 641px)").matches && !firstLoad) {
             $("#glm-enews-sticky").toggleClass('enews-slideout');
+            localStorage.setItem("firstLoad", true);
             // $("#glm-enews-sticky").fadeIn("slow");
         }
         $(document).on("click", ".close-enews", function(){