fix for when the viewport is an element, instead of the window object