7 examples of 'window event listener' in JavaScript

Every line of 'window event listener' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
486_onWindowChanged(event) {
487 const windowPosition = {windowTimeLeft: event.data.rawStartValue, windowTimeRight: event.data.rawEndValue};
488 this._windowTimeLeft = windowPosition.windowTimeLeft;
489 this._windowTimeRight = windowPosition.windowTimeRight;
490
491 this.dispatchEventToListeners(PerfUI.OverviewGrid.Events.WindowChanged, windowPosition);
492}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

82setWindowEventListeners() {
83 this.on('window:reload', function(menuItem, browserWindow) {
84 browserWindow.reload();
85 });
86
87 this.on('window:reset', function(menuItem, browserWindow) {
88 const bounds = AppWindow.DEFAULT_BOUNDS;
89 browserWindow.setSize(bounds.width, bounds.height);
90 browserWindow.center();
91 });
92
93 this.on('window:zoom-in', function(menuItem, browserWindow) {
94 const newLevel = prefs.get('window:zoom-level', 0) + 1;
95 browserWindow.webContents.send('zoom-level', newLevel);
96 prefs.set('window:zoom-level', newLevel);
97 });
98
99 this.on('window:zoom-out', function(menuItem, browserWindow) {
100 const newLevel = prefs.get('window:zoom-level', 0) - 1;
101 browserWindow.webContents.send('zoom-level', newLevel);
102 prefs.set('window:zoom-level', newLevel);
103 });
104
105 this.on('window:toggle-full-screen', function(menuItem, browserWindow) {
106 const newState = !browserWindow.isFullScreen();
107 browserWindow.setFullScreen(newState);
108 });
109
110 this.on('window:toggle-dev-tools', function(menuItem, browserWindow) {
111 browserWindow.toggleDevTools();
112 });
113}
31public addListener(cb: IOneArgFunction<TMessageContent, void>): this {
32 this.callbacks.push(cb);
33 console.info('WindowAdapter: Add iframe message listener');
34 return this;
35}
430function removeMouseButtonWindowListeners(ev) {
431 window.removeEventListener("mousemove", moveMenuButton);
432 window.removeEventListener("mouseup", removeMouseButtonWindowListeners);
433 window.removeEventListener("mouseleave", removeMouseButtonWindowListeners);
434 isMenuButtonDragging = false;
435}
23function addListeners(window, windowId, targetID) {
24 const target = window.document.getElementById(targetID);
25 if (!target) return;
26
27 target.addEventListener('keydown', (ev) => {
28 if (SPECIAL_KEYS.indexOf(ev.which) !== -1) return;
29
30 queryCliqz(ev.key, windowId);
31 target.parentElement.style.visibility = 'hidden';
32 ev.preventDefault();
33 });
34
35 window.addEventListener('click', () => {
36 target.parentElement.style.visibility = 'visible';
37 });
38}
21addListener(listener) {
22 this.listeners.push(listener);
23}
5public listen(win: AbstractWindowController): void {
6 win.on("resize", () => { return; });
7 win.on("blur", () => console.log("blur happen"));
8 win.on("focus", () => {console.log("focus event trigger"); win.send("focus"); });
9 win.on("closed", () => win.closed());
10
11 win.onWebContent("did-finish-load", () => win.init());
12 win.onWebContent("devtools-opened", () => win.setFocusAfterDevToolOpen());
13
14 ipcMain.on("hide", () => win.hide());
15}

Related snippets