It is a separate bug, but I'd guess that this code would work on Desktop if we used window.innerWidth/Height instead of screen.width/height.  I don't know where screen came from here.