export default [
  'wheel',
  isolateScroll,
  { passive: false }
];

function isolateScroll({ originalEvent: event }) {
  let { deltaY, currentTarget } = event;
  let { scrollTop, offsetHeight, scrollHeight } = currentTarget;
  let isAtTop = scrollTop === 0;
  let isAtBottom = offsetHeight + scrollTop === scrollHeight;

  if ((isAtTop && deltaY < 0) || (isAtBottom && deltaY > 0)) {
    event.preventDefault();
  }
}
