I'm looking for some help with coding a function for exit-intent on my website, but instead of classic function like someone moves a cursor away from website I'd like to implement a fast scroll up as a exit-intent. Is it even possible?
I found code like this but it doesn't work for me.
    <script>
setTimeout(() => {
  document.addEventListener("scroll", scrollSpeed);
}, 10000);
scrollSpeed = () => {
  lastPosition = window.scrollY;
  setTimeout(() => {
    newPosition = window.scrollY;
  }, 100);
  currentSpeed = newPosition - lastPosition;
  console.log(currentSpeed);
  if (currentSpeed > 160) {
userengage('event.exit-intent-mobile');
    document.removeEventListener("scroll", scrollSpeed);
  }
};
</script>
I'm getting this error message:
Error at line 2, character 12: This language feature is only supported for ECMASCRIPT_2015 mode or better: arrow function.JavaScript compiler errorUser.com - Exit Intent Mobile
Error at line 5, character 15: This language feature is only supported for ECMASCRIPT_2015 mode or better: arrow function.JavaScript compiler errorUser.com - Exit Intent Mobile
Error at line 7, character 14: This language feature is only supported for ECMASCRIPT_2015 mode or better: arrow function.
Any ideas on how to implement that?