ui.root.onResize
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ลงทะเบียนการเรียกกลับที่จะทริกเกอร์เมื่อสคริปต์เริ่มต้นและเมื่อใดก็ตามที่ขนาดหน้าต่างเบราว์เซอร์เปลี่ยนแปลง ระบบจะส่งออบเจ็กต์ที่มีฟิลด์บูลีน "is_mobile", "is_tablet", "is_desktop", "is_portrait" และ "is_landscape" รวมถึงฟิลด์ตัวเลข "width" และ "height"
ฟิลด์เหล่านี้จะระบุว่าอุปกรณ์ของผู้ใช้เป็นอุปกรณ์เคลื่อนที่ แท็บเล็ต หรือเดสก์ท็อป การวางแนวอุปกรณ์ (แนวตั้งหรือแนวนอน) รวมถึงความกว้างและความสูงของหน้าต่างเป็นพิกเซล ดูส่วนความกว้างและความสูง (dp) ของเมตริกอุปกรณ์ได้ที่ https://material.io/resources/devices/
การใช้งาน | การคืนสินค้า |
---|
ui.root.onResize(callback) | |
อาร์กิวเมนต์ | ประเภท | รายละเอียด |
---|
callback | ฟังก์ชัน | การเรียกกลับที่จะเริ่มทำงานหลังจากปรับขนาดหน้าต่างแล้ว ระบบจะส่งออบเจ็กต์ที่มีข้อมูลของอุปกรณ์ไปยัง Callback |
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 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. |"]]