Commit 56d11492 authored by Phil Hughes's avatar Phil Hughes

moved timeout to a variable

parent 449a84fe
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import bp from './breakpoints'; import bp from './breakpoints';
const HIDE_INTERVAL_TIMEOUT = 300;
const IS_OVER_CLASS = 'is-over'; const IS_OVER_CLASS = 'is-over';
const IS_ABOVE_CLASS = 'is-above'; const IS_ABOVE_CLASS = 'is-above';
const IS_SHOWING_FLY_OUT_CLASS = 'is-showing-fly-out'; const IS_SHOWING_FLY_OUT_CLASS = 'is-showing-fly-out';
...@@ -10,7 +11,7 @@ let timeoutId; ...@@ -10,7 +11,7 @@ let timeoutId;
export const mousePos = []; export const mousePos = [];
export const setOpenMenu = (menu) => { currentOpenMenu = menu; }; export const setOpenMenu = (menu = null) => { currentOpenMenu = menu; };
export const slope = (a, b) => (b.y - a.y) / (b.x - a.x); export const slope = (a, b) => (b.y - a.y) / (b.x - a.x);
...@@ -39,7 +40,7 @@ export const getHideSubItemsInterval = () => { ...@@ -39,7 +40,7 @@ export const getHideSubItemsInterval = () => {
if (slope(prevMousePos, menuBottom) < slope(currentMousePos, menuBottom) && if (slope(prevMousePos, menuBottom) < slope(currentMousePos, menuBottom) &&
slope(prevMousePos, menuTop) > slope(currentMousePos, menuTop)) { slope(prevMousePos, menuTop) > slope(currentMousePos, menuTop)) {
return 300; return HIDE_INTERVAL_TIMEOUT;
} }
return 0; return 0;
...@@ -64,7 +65,7 @@ export const hideMenu = (el) => { ...@@ -64,7 +65,7 @@ export const hideMenu = (el) => {
parentEl.classList.remove(IS_OVER_CLASS); parentEl.classList.remove(IS_OVER_CLASS);
parentEl.classList.remove(IS_SHOWING_FLY_OUT_CLASS); parentEl.classList.remove(IS_SHOWING_FLY_OUT_CLASS);
setOpenMenu(null); setOpenMenu();
}; };
export const moveSubItemsToPosition = (el, subItems) => { export const moveSubItemsToPosition = (el, subItems) => {
...@@ -129,7 +130,10 @@ export const mouseLeaveTopItem = (el) => { ...@@ -129,7 +130,10 @@ export const mouseLeaveTopItem = (el) => {
}; };
export const documentMouseMove = (e) => { export const documentMouseMove = (e) => {
mousePos.push({ x: e.clientX, y: e.clientY }); mousePos.push({
x: e.clientX,
y: e.clientY,
});
if (mousePos.length > 6) mousePos.shift(); if (mousePos.length > 6) mousePos.shift();
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment