Simplify the logic in setViewportSize function in timelapse.js