StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.6 KiB
47 lines
1.6 KiB
4 years ago
|
import { hasPassiveEventSupport } from './env';
|
||
|
import { isObject } from './inspect'; // --- Constants ---
|
||
|
|
||
|
export var EVENT_OPTIONS_PASSIVE = {
|
||
|
passive: true
|
||
|
};
|
||
|
export var EVENT_OPTIONS_NO_CAPTURE = {
|
||
|
passive: true,
|
||
|
capture: false
|
||
|
}; // --- Utils ---
|
||
|
// Normalize event options based on support of passive option
|
||
|
// Exported only for testing purposes
|
||
|
|
||
|
export var parseEventOptions = function parseEventOptions(options) {
|
||
|
/* istanbul ignore else: can't test in JSDOM, as it supports passive */
|
||
|
if (hasPassiveEventSupport) {
|
||
|
return isObject(options) ? options : {
|
||
|
capture: !!options || false
|
||
|
};
|
||
|
} else {
|
||
|
// Need to translate to actual Boolean value
|
||
|
return !!(isObject(options) ? options.capture : options);
|
||
|
}
|
||
|
}; // Attach an event listener to an element
|
||
|
|
||
|
export var eventOn = function eventOn(el, evtName, handler, options) {
|
||
|
if (el && el.addEventListener) {
|
||
|
el.addEventListener(evtName, handler, parseEventOptions(options));
|
||
|
}
|
||
|
}; // Remove an event listener from an element
|
||
|
|
||
|
export var eventOff = function eventOff(el, evtName, handler, options) {
|
||
|
if (el && el.removeEventListener) {
|
||
|
el.removeEventListener(evtName, handler, parseEventOptions(options));
|
||
|
}
|
||
|
}; // Utility method to add/remove a event listener based on first argument (boolean)
|
||
|
// It passes all other arguments to the `eventOn()` or `eventOff` method
|
||
|
|
||
|
export var eventOnOff = function eventOnOff(on) {
|
||
|
var method = on ? eventOn : eventOff;
|
||
|
|
||
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
||
|
args[_key - 1] = arguments[_key];
|
||
|
}
|
||
|
|
||
|
method.apply(void 0, args);
|
||
|
};
|