ui.root.onResize
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Enregistre un rappel qui est déclenché au démarrage du script et chaque fois que la taille de la fenêtre du navigateur change. Un objet lui sera transmis avec les champs booléens "is_mobile", "is_tablet", "is_desktop", "is_portrait" et "is_landscape", ainsi que les champs numériques "width" et "height".
Ces champs indiquent si l'appareil d'un utilisateur est un mobile, une tablette ou un ordinateur de bureau, l'orientation de l'appareil (portrait ou paysage), ainsi que la largeur et la hauteur de la fenêtre en pixels. Consultez la section "Largeur et hauteur (dp)" des métriques des appareils sur https://material.io/resources/devices/.
Utilisation | Renvoie |
---|
ui.root.onResize(callback) | |
Argument | Type | Détails |
---|
callback | Fonction | Rappel à déclencher une fois la fenêtre redimensionnée. Le rappel reçoit un objet contenant les informations de l'appareil. |
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[null,null,["Dernière mise à jour le 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. |"]]