When changing route, change viewport size

So, I am routing pages via click event using iron:router. To be specific I am using the following command

Router.go("/profile")

The page does indeed get routed to the appropriate page, however, the viewport size remains the same as the previous page.

When changing routes with client-side routers the browser doesn’t technically load a new page, it just changes content in the existing page (as far as the browser is concerned) so it doesn’t scroll to the top. The viewport stays in the same place and size as it was already. I can use https://github.com/okgrow/router-autoscroll to autoscroll but how do I render the viewport to the size of the new “page”

Try specifying window.resizeTo() in the onAfterAction() in the Iron Router route.

Meteor Cookbook - Window Resizing

1 Like

Thanks, that worked. .

@awatson1978 that’s an awesome resource.