From 8940caced399749c720ed40f5c4bcdc0534fd0e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Krakowski?= Date: Tue, 29 Oct 2019 11:19:19 +0100 Subject: [PATCH 1/3] fix(): sources catalog --- js/anchors-indicator/index.js | 5 +-- .../sidebar/destination-menu-mobile.html | 2 +- src/_includes/sidebar/source-menu-mobile.html | 2 +- src/_layouts/catalog.html | 44 +------------------ .../components/_destination-menu-mobile.scss | 1 + 5 files changed, 5 insertions(+), 49 deletions(-) diff --git a/js/anchors-indicator/index.js b/js/anchors-indicator/index.js index 24156f0af4..df94931b61 100644 --- a/js/anchors-indicator/index.js +++ b/js/anchors-indicator/index.js @@ -2,9 +2,6 @@ const COMPONENT_SELECTOR = '[data-anchors-indicator]' const ACTIVE_CLASS = 'data-active-class' const SECTION_ATTR= 'data-sections' -const options = { - rootMargin: 50 -} const throttle = (fn, wait) => { var time = Date.now(); @@ -30,7 +27,7 @@ export default () => { let currentElementOffset = current.offsetTop; let scrollPosition = document.documentElement.scrollTop || document.body.scrollTop; - if (currentElementOffset <= scrollPosition + options.rootMargin) { + if (currentElementOffset <= scrollPosition + (window.innerHeight / 2)) { allLinks.forEach(currentLink => { currentLink.classList.remove(activeClass); }); diff --git a/src/_includes/sidebar/destination-menu-mobile.html b/src/_includes/sidebar/destination-menu-mobile.html index dd773d3366..47b9fd61c4 100644 --- a/src/_includes/sidebar/destination-menu-mobile.html +++ b/src/_includes/sidebar/destination-menu-mobile.html @@ -3,7 +3,7 @@
- + Choose category diff --git a/src/_includes/sidebar/source-menu-mobile.html b/src/_includes/sidebar/source-menu-mobile.html index 8b98672fba..94fcd6a39c 100644 --- a/src/_includes/sidebar/source-menu-mobile.html +++ b/src/_includes/sidebar/source-menu-mobile.html @@ -3,7 +3,7 @@
- + Choose category diff --git a/src/_layouts/catalog.html b/src/_layouts/catalog.html index 66569b53ee..00853f7a63 100644 --- a/src/_layouts/catalog.html +++ b/src/_layouts/catalog.html @@ -32,49 +32,7 @@

-
- {% assign categories = site.data.catalogV2.destination_categories.items %} - - {% for category in categories %} -
- {% assign category_icon = category.slug | slugify %} - -

- {% include icons/destinations-catalog/{{ category_icon }}.svg %} - - {{ category.display_name }} -

- -
- {% assign destinations = site.data.catalogV2.destinations.items | where: "categories", category.display_name %} - - {% for destination in destinations %} - {% if destination.status contains "PUBLIC" or destination.status contains "BETA" %} - - {% endif %} - {% endfor %} -
-
- {% endfor %} -
+ {{ content }}

diff --git a/src/_sass/components/_destination-menu-mobile.scss b/src/_sass/components/_destination-menu-mobile.scss index 86c5e4c75c..77c3af64f1 100644 --- a/src/_sass/components/_destination-menu-mobile.scss +++ b/src/_sass/components/_destination-menu-mobile.scss @@ -7,6 +7,7 @@ position: -webkit-sticky; top: 0; z-index: 1; + max-height: 80px; @include breakpoint(large up) { display: none; From a2f2a2e738a1db9be660b8d3066a8ec43f2e89f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Krakowski?= Date: Tue, 29 Oct 2019 13:43:48 +0100 Subject: [PATCH 2/3] fix(): Fix menuspy and Safarii topbar --- js/anchors-indicator/index.js | 18 ++++++++++++++---- .../sidebar/destination-menu-mobile.html | 2 +- src/_includes/sidebar/source-menu-mobile.html | 2 +- .../components/_destinations-catalog.scss | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/js/anchors-indicator/index.js b/js/anchors-indicator/index.js index df94931b61..04512ca6e2 100644 --- a/js/anchors-indicator/index.js +++ b/js/anchors-indicator/index.js @@ -24,10 +24,18 @@ export default () => { function scrollspy() { sections.forEach(current => { - let currentElementOffset = current.offsetTop; - let scrollPosition = - document.documentElement.scrollTop || document.body.scrollTop; - if (currentElementOffset <= scrollPosition + (window.innerHeight / 2)) { + let currentElementOffset = current.offsetTop + let scrollPosition = document.documentElement.scrollTop || document.body.scrollTop + + let position = null + + if (window.innerWidth >= 768) { + position = scrollPosition + (window.innerHeight * 0.2) + } else { + position = scrollPosition + (window.innerHeight * 0.6) + } + + if (currentElementOffset <= position) { allLinks.forEach(currentLink => { currentLink.classList.remove(activeClass); }); @@ -41,6 +49,8 @@ export default () => { } }); } + + window.addEventListener('load', scrollspy()) window.addEventListener("scroll", throttle(scrollspy, 200)) }) } diff --git a/src/_includes/sidebar/destination-menu-mobile.html b/src/_includes/sidebar/destination-menu-mobile.html index 47b9fd61c4..85f710096f 100644 --- a/src/_includes/sidebar/destination-menu-mobile.html +++ b/src/_includes/sidebar/destination-menu-mobile.html @@ -1,6 +1,6 @@ {% assign categories = site.data.catalogV2.destination_categories.items %} -
+
diff --git a/src/_includes/sidebar/source-menu-mobile.html b/src/_includes/sidebar/source-menu-mobile.html index 94fcd6a39c..1af20b0dac 100644 --- a/src/_includes/sidebar/source-menu-mobile.html +++ b/src/_includes/sidebar/source-menu-mobile.html @@ -1,6 +1,6 @@ {% assign destination_categories = site.data.catalogV2.source_categories.items | sort: "name" %} -
+
diff --git a/src/_sass/components/_destinations-catalog.scss b/src/_sass/components/_destinations-catalog.scss index 4b717afe16..b3330d059e 100644 --- a/src/_sass/components/_destinations-catalog.scss +++ b/src/_sass/components/_destinations-catalog.scss @@ -13,7 +13,7 @@ svg { width: 24px; height: 24px; - color: color(secondary); + color: color(secondary); } } } From 0a008c49ff347e6a82f378ce5523773a2802121c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Krakowski?= Date: Tue, 29 Oct 2019 15:31:27 +0100 Subject: [PATCH 3/3] fix(): Reduction throttle --- js/anchors-indicator/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/anchors-indicator/index.js b/js/anchors-indicator/index.js index 04512ca6e2..aeaa54ec86 100644 --- a/js/anchors-indicator/index.js +++ b/js/anchors-indicator/index.js @@ -51,6 +51,6 @@ export default () => { } window.addEventListener('load', scrollspy()) - window.addEventListener("scroll", throttle(scrollspy, 200)) + window.addEventListener("scroll", throttle(scrollspy, 50)) }) }