open-nomad/ui/app/modifiers/window-resize.js
2023-04-10 15:36:59 +00:00

16 lines
377 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { modifier } from 'ember-modifier';
export default modifier(function windowResize(element, [handler]) {
const boundHandler = (ev) => handler(element, ev);
window.addEventListener('resize', boundHandler);
return () => {
window.removeEventListener('resize', boundHandler);
};
});