From b29a7504f28b8f02e0e88bd9d5624ddfe694cfbc Mon Sep 17 00:00:00 2001 From: Minghua Sun Date: Mon, 17 May 2021 15:23:08 -0400 Subject: [PATCH] test and wip --- .../source/assets/js/modules/mapLeaflet.js | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/patternlab/styleguide/source/assets/js/modules/mapLeaflet.js b/packages/patternlab/styleguide/source/assets/js/modules/mapLeaflet.js index 5ce4703e38..a0bf462bc1 100644 --- a/packages/patternlab/styleguide/source/assets/js/modules/mapLeaflet.js +++ b/packages/patternlab/styleguide/source/assets/js/modules/mapLeaflet.js @@ -146,16 +146,34 @@ export default (function (window,document) { mymap.addControl(new customControl()); + const disablePageScroll = () => { + // Get the current page scroll position + scrollTop = window.pageYOffset || document.documentElement.scrollTop; + scrollLeft = window.pageXOffset || document.documentElement.scrollLeft, + + // if any scroll is attempted, set this to the previous value + window.onscroll = function() { + window.scrollTo(scrollLeft, scrollTop); + }; + } + + const enablePageScroll = () => { + window.onscroll = function() {}; + } + const container = L.DomUtil.get(containerID); const unlockMove = () => { + const target = document.activeElement; + console.log(target, 'unlock') locked = false; container.innerHTML = setStatusText(locked); //mymap.scrollWheelZoom.enable(); mymap.dragging.enable(); } - const lockMove = () => { + const lockMove = (target) => { + console.log(target, 'lock') locked = true; container.innerHTML = setStatusText(locked); mymap.scrollWheelZoom.disable(); @@ -169,7 +187,7 @@ export default (function (window,document) { const customBlur = (target) => { const inMap = mapWrapper.contains(target) if (!inMap) { - lockMove(); + lockMove(target); } } @@ -180,6 +198,7 @@ export default (function (window,document) { document.onkeyup = (e) => { if (e.key == 'Tab') { + console.log('on tab blur') const target = document.activeElement; customBlur(target) }