diff --git a/visual-viewport-api/main.js b/visual-viewport-api/main.js index e296483..15390c7 100644 --- a/visual-viewport-api/main.js +++ b/visual-viewport-api/main.js @@ -15,15 +15,15 @@ const scrollendUpdater = () => { }; function updateText() { - visualInfo.innerText = `Visual viewport top: ${visualViewport.offsetTop.toFixed(2)} left: ${visualViewport.offsetLeft.toFixed(2)}`; + visualInfo.innerText = `Visual viewport left: ${visualViewport.offsetLeft.toFixed(2)} top: ${visualViewport.offsetTop.toFixed(2)}`; windowInfo.innerText = `Window scrollX: ${window.scrollX.toFixed(2)} scrollY: ${window.scrollY.toFixed(2)}`; } +updateText(); + visualViewport.onresize = scrollUpdater; visualViewport.onscroll = scrollUpdater; visualViewport.onscrollend = scrollendUpdater; window.onresize = scrollUpdater; window.onscroll = scrollUpdater; window.onscrollend = scrollendUpdater; - -updateText();