added a condition to check the width of the viewport

should this conditional be inside the click handler so it's checked again if the user resizes the screen?