Adding class based on direction