Fixing time comparison in scrollToElement if time is specified