ui.root.onResize
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
רושם קריאה חוזרת (callback) שמופעלת כשהסקריפט מתחיל וכשגודל חלון הדפדפן משתנה. הפונקציה תקבל אובייקט עם שדות בוליאניים is_mobile, is_tablet, is_desktop, is_portrait ו-is_landscape, ושדות מספריים width ו-height.
בשדות האלה מצוין אם המכשיר של המשתמש הוא נייד, טאבלט או מחשב, אוריינטציית המכשיר (לאורך או לרוחב) והרוחב והגובה של החלון בפיקסלים. אפשר לעיין בקטע 'רוחב וגובה (dp)' במדדי המכשירים בכתובת https://material.io/resources/devices/.
שימוש | החזרות |
---|
ui.root.onResize(callback) | |
ארגומנט | סוג | פרטים |
---|
callback | פונקציה | הקריאה החוזרת שמופעלת אחרי שינוי הגודל של החלון. פונקציית הקריאה החוזרת מקבלת אובייקט עם פרטי המכשיר. |
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-26 (שעון UTC)."],[[["\u003cp\u003eTriggers a provided function when the webpage loads or the browser window is resized.\u003c/p\u003e\n"],["\u003cp\u003eProvides details about the device used, such as whether it is a mobile, tablet, or desktop, its orientation (portrait or landscape), and the window's dimensions in pixels.\u003c/p\u003e\n"],["\u003cp\u003eUtilizes boolean fields ("is_mobile", "is_tablet", "is_desktop", "is_portrait", "is_landscape") and numeric fields ("width", "height") within a passed object to convey device information.\u003c/p\u003e\n"],["\u003cp\u003eCan be implemented using \u003ccode\u003eui.root.onResize(callback)\u003c/code\u003e, where \u003ccode\u003ecallback\u003c/code\u003e represents the function to be executed.\u003c/p\u003e\n"]]],[],null,["# ui.root.onResize\n\n\u003cbr /\u003e\n\nRegisters a callback that's fired when the script starts and whenever the browser window size changes. It will be passed an object with boolean fields \"is_mobile\", \"is_tablet\", \"is_desktop\", \"is_portrait\" and \"is_landscape\", and numeric fields \"width\" and \"height\".\n\n\u003cbr /\u003e\n\nThese fields indicate whether a user's device is mobile, tablet or desktop, the device orientation (portrait or landscape), and the width and height of the window in pixels. See the Width and Height (dp) section of device metrics at https://material.io/resources/devices/.\n\n| Usage | Returns |\n|------------------------------|---------|\n| `ui.root.onResize(callback)` | |\n\n| Argument | Type | Details |\n|------------|----------|------------------------------------------------------------------------------------------------------------------------------|\n| `callback` | Function | The callback to fire after the window has been resized. The callback is passed an object with the information of the device. |"]]