interface EventListeners {
  element: HTMLElement | null;
  onScroll: () => void;
  onTouchStart: () => void;
  onTouchMove: () => void;
  onTouchEnd: () => void;
}

export const addEventListeners = ({ element, onScroll, onTouchStart, onTouchMove, onTouchEnd }: EventListeners) => {
  element?.addEventListener('scroll', onScroll);
  element?.addEventListener('touchstart', onTouchStart, { passive: true });
  element?.addEventListener('touchmove', onTouchMove, { passive: true });
  element?.addEventListener('touchend', onTouchEnd, { passive: true });
};

export const removeEventListeners = ({ element, onScroll, onTouchStart, onTouchMove, onTouchEnd }: EventListeners) => {
  element?.removeEventListener('scroll', onScroll);
  element?.removeEventListener('touchstart', onTouchStart);
  element?.removeEventListener('touchmove', onTouchMove);
  element?.removeEventListener('touchend', onTouchEnd);
};
