Combine if-statements to a single one
Don't add/remove CSS-classes if not necessary

Maybe this fixes the scrolling slowdown