How to get the window size with Browser.Dom?

When you talk about the “viewport” I guess you talk about the viewport property of the svg element, and not the visual viewport of the page? All this gets sometime confusing. Especially with svg sizing. Anyway, it’s not always necessary to use the “viewport” property to manage positionning and zooming in an SVG drawing. In fact I’ve had a lot of dealing with this for specific use cases where the SVG element is filling the space available in the page, (with flexbox or elm-ui) so it never displays scroll bars.

I have made a repo (not published package) with the code I use to manage this: GitHub - mpizenberg/elm-2d-viewer: A 2D (image) viewer with zoom and pan in mind. Don’t hesitate to have a look for inspiration.

The only requirement is that you know the size of the viewer. In my case I have a port sending the new page size on resize and I can deduce the viewer size.