not trying to re-open an old post, but if someone ends up here trying to figure out how to accomplish this, I did do something basically like this via a phx-hook described in this post:
There are three pieces to it:
div called page_resize
hook called PageResize
handle_event called page-resize
Now that alpinejs works with LiveView I think it would be possible to do with that as well, but I was unable to get the .window modifier to work with LiveView.