From f37a2bd0a87eed59aeaa2feec3056e81884f7768 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 15 Feb 2019 16:31:04 +0100 Subject: [PATCH] Change js depending of window with --- app/assets/javascripts/foundation_extras.js.coffee | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/foundation_extras.js.coffee b/app/assets/javascripts/foundation_extras.js.coffee index 7beb05f93..c12a2de92 100644 --- a/app/assets/javascripts/foundation_extras.js.coffee +++ b/app/assets/javascripts/foundation_extras.js.coffee @@ -2,7 +2,6 @@ App.FoundationExtras = initialize: -> $(document).foundation() - $(window).trigger "init.zf.sticky" $(window).trigger "resize" clearSticky = -> @@ -11,3 +10,15 @@ App.FoundationExtras = $(document).on("page:before-unload", clearSticky) window.addEventListener("popstate", clearSticky, false) + + mobile_ui_init = -> + $(window).trigger "load.zf.sticky" + + desktop_ui_init = -> + $(window).trigger "init.zf.sticky" + + $ -> + if $(window).width() < 620 + do mobile_ui_init + else + do desktop_ui_init