inferno icon indicating copy to clipboard operation
inferno copied to clipboard

Support Passive Event Listeners

Open mciparelli opened this issue 9 years ago • 7 comments

It would be nice to have support for passive events. Related: https://github.com/facebook/react/issues/6436

mciparelli avatar Sep 21 '16 15:09 mciparelli

Currently Inferno adds events using inline way. equivalent to:

<div onclick="function() {}"></div>

To support this feature new way of handling methods is needed. We used to use addEventListener, but that resulted memory leaks and slow rendering because of removeEventListener (to avoid that leak).

Havunen avatar Sep 21 '16 17:09 Havunen

@Havunen this is now a possibility again with our new event system.

trueadm avatar Dec 04 '16 22:12 trueadm

Let's revisit this post 1.0.

trueadm avatar Dec 23 '16 21:12 trueadm

Add to roadmap @lukeed

trueadm avatar Dec 23 '16 21:12 trueadm

Re-opening as this was never implemented

Havunen avatar Apr 11 '17 14:04 Havunen

This looks good, this would have effects in performance. But as far as I have read, this would only be applicable for events that's related to scrolling --> https://developers.google.com/web/tools/lighthouse/audits/passive-event-listeners. Inferno could handle it by supporting event options like so:

<span onScroll={{
  handler (ev) {
    // do something
  },
  options: {
    passive: true
  }
}}>

OR adding it automatically when the event listener is related to scrolling.

There's even a demo video about this --> https://youtu.be/65VMej8n23A

I think it's good for inferno to support passive listener for onScroll by default.

aprilmintacpineda avatar Jan 31 '19 08:01 aprilmintacpineda