@qhealth-design-system/core 1.18.3 → 1.18.4
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/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -22,6 +22,8 @@ let isHeaderOpen = false;
|
|
|
22
22
|
let headerSearchEvents = {};
|
|
23
23
|
// Breakpoint for mobile mode
|
|
24
24
|
const mobileBreakpoint = 992;
|
|
25
|
+
// Hold width value to detect resize
|
|
26
|
+
let lastWidth = window.innerWidth;
|
|
25
27
|
|
|
26
28
|
export default function initHeader(document = document) {
|
|
27
29
|
// Add action so the search works only if JS is enabled
|
|
@@ -40,6 +42,11 @@ export default function initHeader(document = document) {
|
|
|
40
42
|
|
|
41
43
|
// We want to ensure the search input is visible on desktop at all times
|
|
42
44
|
window.addEventListener("resize", () => {
|
|
45
|
+
const currentWidth = window.innerWidth;
|
|
46
|
+
// Ignore resize events that do not change the viewport size. Required for Android devices
|
|
47
|
+
if (currentWidth === lastWidth) return;
|
|
48
|
+
else lastWidth = currentWidth;
|
|
49
|
+
|
|
43
50
|
if (window.innerWidth >= mobileBreakpoint && !isHeaderOpen) {
|
|
44
51
|
openHeader(false);
|
|
45
52
|
// Disable focus trap as it's not needed on desktop
|
|
@@ -225,5 +232,5 @@ function addEvent(element, event, rawHandler) {
|
|
|
225
232
|
* @param {event} token The event to remove
|
|
226
233
|
*/
|
|
227
234
|
function removeEvent(token) {
|
|
228
|
-
token.element.removeEventListener(token.event, token.handler);
|
|
235
|
+
if (token && token.element) token.element.removeEventListener(token.event, token.handler);
|
|
229
236
|
}
|