@elvia/elvis-toolbox
Advanced tools
Comparing version 1.0.1 to 1.2.0
@@ -11,4 +11,38 @@ /* | ||
const outlineListener = (element, destroy) => { | ||
if (!element) { | ||
return; | ||
} | ||
const addOutline = e => { | ||
if (e.key === 'Tab' && element.classList.contains('ewc-no-outline')) { | ||
element.classList.remove('ewc-no-outline'); // Add mousedown event-listener to remove outline again | ||
element.addEventListener('mousedown', removeOutline, false); | ||
} | ||
}; | ||
const removeOutline = () => { | ||
if (!element.classList.contains('ewc-no-outline')) { | ||
element.classList.add('ewc-no-outline'); // Remove mousedown event-listener until next tab happens | ||
element.removeEventListener('mousedown', removeOutline, false); | ||
} | ||
}; // If destroy is true -> Remove all listeners and return | ||
if (destroy) { | ||
element.removeEventListener('keydown', addOutline); | ||
element.removeEventListener('mousedown', removeOutline, false); | ||
return; | ||
} // Start listening for keyboard-events and mousedown on element to add or remove outline | ||
element.addEventListener('keydown', addOutline); | ||
element.addEventListener('mousedown', removeOutline, false); | ||
}; | ||
export default { | ||
throttle: throttle | ||
throttle: throttle, | ||
outlineListener: outlineListener | ||
}; |
{ | ||
"name": "@elvia/elvis-toolbox", | ||
"version": "1.0.1", | ||
"version": "1.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/elvis-toolbox.js", |
@@ -7,2 +7,35 @@ import * as lodashThrottle from 'lodash.throttle'; | ||
export default { throttle: throttle }; | ||
const outlineListener = (element: HTMLElement, destroy?: boolean): void => { | ||
if (!element) { | ||
return; | ||
} | ||
const addOutline = (e: KeyboardEvent) => { | ||
if (e.key === 'Tab' && element.classList.contains('ewc-no-outline')) { | ||
element.classList.remove('ewc-no-outline'); | ||
// Add mousedown event-listener to remove outline again | ||
element.addEventListener('mousedown', removeOutline, false); | ||
} | ||
}; | ||
const removeOutline = () => { | ||
if (!element.classList.contains('ewc-no-outline')) { | ||
element.classList.add('ewc-no-outline'); | ||
// Remove mousedown event-listener until next tab happens | ||
element.removeEventListener('mousedown', removeOutline, false); | ||
} | ||
}; | ||
// If destroy is true -> Remove all listeners and return | ||
if (destroy) { | ||
element.removeEventListener('keydown', addOutline); | ||
element.removeEventListener('mousedown', removeOutline, false); | ||
return; | ||
} | ||
// Start listening for keyboard-events and mousedown on element to add or remove outline | ||
element.addEventListener('keydown', addOutline); | ||
element.addEventListener('mousedown', removeOutline, false); | ||
}; | ||
export default { throttle: throttle, outlineListener: outlineListener }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3233
68