From bfc9fb5852129857ceb9c79b3502dd24b2c70c40 Mon Sep 17 00:00:00 2001 From: MinSoo Kim Date: Sun, 12 Feb 2017 11:07:52 +0900 Subject: [PATCH] Fix layout - not to fire fade in/out actions on the iOS devices. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit iOS 기기에서 햄버거 메뉴가 여러번 나타났다 사라지는 오류가 있었기에 수정합니다. --- layouts/simple_world/layout.js | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/layouts/simple_world/layout.js b/layouts/simple_world/layout.js index 991671b26..6e2798cbf 100644 --- a/layouts/simple_world/layout.js +++ b/layouts/simple_world/layout.js @@ -31,29 +31,48 @@ $(function() }); }); - /* detect scrolling up or down to hide or show hamburger menu */ + /* detect scrolling up or down to hide or show the hamburger menu */ var previousScroll = 0; + var simpleScrolled = false; + var scrollThreshold = 5; + + /* detect window scrolling */ $( window ).scroll(function() { - var currentScroll = $(this).scrollTop(); + simpleScrolled = true; + }); + + /* refresh window scrolling per 250 ms, and show/hide the menu */ + setInterval(function() + { + if (simpleScrolled) { + display_menu(); + simpleScrolled = false; + } + }, 250); + + /* function to show/hide the menu */ + var display_menu = function() + { + var currentScroll = $(window).scrollTop(); + if (currentScroll > previousScroll) { - if($("#layout_menu_toggle").css( 'position' ) === 'fixed' && $("#layout_menu_toggle").attr('data-scroll-down') !== 'true') + if($("#layout_menu_toggle").css( 'position' ) === 'fixed') { - $("#layout_menu_toggle").attr('data-scroll-down', 'true'); $("#layout_menu_toggle").fadeOut(); } } else { - if($("#layout_menu_toggle").css( 'position' ) === 'fixed' && $("#layout_menu_toggle").attr('data-scroll-down') === 'true') + if($("#layout_menu_toggle").css( 'position' ) === 'fixed') { - $("#layout_menu_toggle").attr('data-scroll-down', ''); $("#layout_menu_toggle").fadeIn(); + $("#layout_menu_toggle").css('display', ''); } } previousScroll = currentScroll; - }); + } /* keyboard accessibility for dropdown menu */ $(".layout_dropdown").each(function()