mirror of
https://github.com/rio-labs/rio.git
synced 2026-05-20 03:18:36 -05:00
window resize event bugfix
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { getComponentByElement } from './componentManagement';
|
||||
import { eventRateLimiter } from './eventRateLimiter';
|
||||
import { updateLayout } from './layouting';
|
||||
import { callRemoteMethodDiscardResponse, initWebsocket } from './rpc';
|
||||
import { scrollToUrlFragment } from './utils';
|
||||
@@ -55,17 +56,17 @@ export let pixelsPerRem = 16;
|
||||
export let scrollBarSize = SCROLL_BAR_SIZE_IN_PIXELS / pixelsPerRem;
|
||||
|
||||
let notifyBackendOfWindowSizeChange = eventRateLimiter(
|
||||
(newWidth: number, newHeight: number) => {
|
||||
(newWidthPx: number, newHeightPx: number) => {
|
||||
try {
|
||||
callRemoteMethodDiscardResponse('onWindowSizeChange', {
|
||||
newWidth: newWidth,
|
||||
newHeight: newHeight,
|
||||
newWidth: newWidthPx / pixelsPerRem,
|
||||
newHeight: newHeightPx / pixelsPerRem,
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn(`Couldn't notify backend of window resize: ${e}`);
|
||||
}
|
||||
},
|
||||
250
|
||||
500
|
||||
);
|
||||
|
||||
function main(): void {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* @param delay - The delay in milliseconds between function calls.
|
||||
* @returns A function that removes the event listener.
|
||||
*/
|
||||
function eventRateLimiter(
|
||||
export function eventRateLimiter(
|
||||
callback: (...args: any[]) => void,
|
||||
delay: number
|
||||
): (...args: any[]) => void {
|
||||
@@ -22,6 +22,7 @@ function eventRateLimiter(
|
||||
|
||||
// If a timeout is already set, do nothing
|
||||
if (timeout) {
|
||||
console.trace('Eating');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user