@ably/ui 8.1.1 → 8.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/Meganav/component.js +1 -1
- package/core/Meganav.jsx +46 -27
- package/core/MeganavBlogPostsList/component.js +1 -1
- package/core/MeganavContentPlatform.jsx +27 -20
- package/core/MeganavItemsSignedIn.jsx +1 -1
- package/core/MeganavSearch.jsx +1 -1
- package/core/MeganavSearchPanel.jsx +1 -1
- package/core/MeganavSearchSuggestions/component.js +1 -1
- package/core/Notice/component.js +1 -1
- package/core/scripts.js +1 -1
- package/package.json +1 -1
- package/src/core/MeganavContentPlatform/component.html.erb +24 -18
- package/src/core/MeganavContentPlatform/component.jsx +25 -20
- package/src/core/MeganavSearchPanel/component.html.erb +1 -1
- package/src/core/MeganavSearchPanel/component.jsx +1 -1
- package/src/core/MeganavSearchSuggestions/component.html.erb +2 -2
- package/src/core/MeganavSearchSuggestions/component.js +15 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<p class="ui-text-overline2 text-cool-black py-12">Popular pages</p>
|
|
2
2
|
|
|
3
|
-
<div class="flex justify-between items-center overflow-
|
|
4
|
-
<ul class="flex">
|
|
3
|
+
<div class="flex justify-between items-center overflow-hidden">
|
|
4
|
+
<ul class="flex transition-transform">
|
|
5
5
|
<li class="py-12 pr-8 flex-shrink-0">
|
|
6
6
|
<%= link_to 'How does Ably work?', abs_url("/docs/how-ably-works"), class: "ui-text-p2 hover:text-gui-hover active:text-gui-active focus:text-gui-focus" %>
|
|
7
7
|
</li>
|
|
@@ -18,15 +18,16 @@ const getDistance = (e, touchStartX) =>
|
|
|
18
18
|
|
|
19
19
|
const withinBuffer = (distance) => Math.abs(distance) < DRAG_BUFFER;
|
|
20
20
|
|
|
21
|
+
const getItemsTotalWidth = (nodes) =>
|
|
22
|
+
nodes
|
|
23
|
+
.map((item) => item.getBoundingClientRect().width)
|
|
24
|
+
.reduce((acc, val) => acc + val, 0);
|
|
25
|
+
|
|
21
26
|
const MeganavSearchSuggestions = () => {
|
|
22
27
|
const suggestionsToggle = queryId("meganav-mobile-search-input");
|
|
23
28
|
const suggestions = queryId("meganav-mobile-search-suggestions");
|
|
24
29
|
const list = suggestions.querySelector("ul");
|
|
25
|
-
const listItems = list.querySelectorAll("li");
|
|
26
|
-
|
|
27
|
-
const itemsTotalWidth = Array.from(listItems)
|
|
28
|
-
.map((item) => item.getBoundingClientRect().width)
|
|
29
|
-
.reduce((acc, val) => acc + val, 0);
|
|
30
|
+
const listItems = Array.from(list.querySelectorAll("li"));
|
|
30
31
|
|
|
31
32
|
const dragLeft = (distance, threshold) => {
|
|
32
33
|
const currentTranslateX = getTranslateX(list);
|
|
@@ -50,6 +51,7 @@ const MeganavSearchSuggestions = () => {
|
|
|
50
51
|
const listWidth = list.getBoundingClientRect().width;
|
|
51
52
|
const currentTranslateX = getTranslateX(list);
|
|
52
53
|
const translateX = Math.round(currentTranslateX + distance);
|
|
54
|
+
const itemsTotalWidth = getItemsTotalWidth(listItems);
|
|
53
55
|
|
|
54
56
|
if (dragRightBoundary(translateX, itemsTotalWidth, listWidth, threshold)) {
|
|
55
57
|
return;
|
|
@@ -61,6 +63,7 @@ const MeganavSearchSuggestions = () => {
|
|
|
61
63
|
const dragRightEnd = (distance, threshold) => {
|
|
62
64
|
const listWidth = list.getBoundingClientRect().width;
|
|
63
65
|
const currentTranslateX = getTranslateX(list);
|
|
66
|
+
const itemsTotalWidth = getItemsTotalWidth(listItems);
|
|
64
67
|
let translateX = Math.round(currentTranslateX + distance);
|
|
65
68
|
|
|
66
69
|
if (dragRightBoundary(translateX, itemsTotalWidth, listWidth, threshold)) {
|
|
@@ -99,11 +102,18 @@ const MeganavSearchSuggestions = () => {
|
|
|
99
102
|
suggestions.classList.remove("max-h-96");
|
|
100
103
|
};
|
|
101
104
|
|
|
105
|
+
const wheelHandler = (e) => {
|
|
106
|
+
const distance = e.deltaY * 4;
|
|
107
|
+
if (withinBuffer(distance)) return;
|
|
108
|
+
distance > 0 ? dragLeftEnd(distance, 24) : dragRightEnd(distance, 48);
|
|
109
|
+
};
|
|
110
|
+
|
|
102
111
|
suggestionsToggle.addEventListener("focus", focusSuggestionsHandler);
|
|
103
112
|
suggestionsToggle.addEventListener("blur", blurSuggestionsHandler);
|
|
104
113
|
suggestions.addEventListener("touchstart", touchstartHandler);
|
|
105
114
|
suggestions.addEventListener("touchmove", touchmoveHandler);
|
|
106
115
|
suggestions.addEventListener("touchend", touchendHandler);
|
|
116
|
+
suggestions.addEventListener("wheel", wheelHandler);
|
|
107
117
|
|
|
108
118
|
return {
|
|
109
119
|
teardown: () => {
|