asp-smart-ui-plus-test
Version:
A Component Library for Vue 3
20 lines (18 loc) • 437 B
JavaScript
function hasWindow() {
return typeof window !== "undefined";
}
function addWindowEventListener(event, callback) {
if (!hasWindow) {
callback();
return false;
}
window.addEventListener(event, callback);
return true;
}
function removeWindowEventListener(event, callback) {
if (!hasWindow) {
return;
}
window.removeEventListener(event, callback);
}
export { addWindowEventListener, removeWindowEventListener };