revises js function for navbar animation