You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{render}from"solid-js/web";import{onMount}from"solid-js";functionCounter(){constwheel=(e:MouseEvent)=>{e.preventDefault()// only works on not passive eventse.stopPropagation()console.log("wheel stopped?")}letdiv;onMount(()=>div.addEventListener("wheel",wheel,{passive:false}))// most events are not passive by default but "wheel" is in Chromereturn(<><divoncapture:wheel={wheel}style={{"background-color":"lightgreen","height":"26vh"}}/><divref={div}style={{"background-color":"lightgray","height":"26vh"}}> In Chrome this gray div is the only div that prevents scrolling</div><divon:wheel={wheel}style={{"background-color":"lightblue","height":"26vh"}}/><divonWheel={wheel}style={{"background-color":"crimson","height":"26vh"}}/></>);}render(()=><Counter/>,document.getElementById("app")!);
Like on:* and oncapture:*
There could be a JSX syntax to specify the passive option for events. Maybe onpassive:* and onnotpassive: * or onWheelNotPassive and onScrollNotPassive
Screenshots or Videos
No response
Platform
only in Chrome AFAIK
Additional context
No response
The text was updated successfully, but these errors were encountered:
goswinr
changed the title
Support Passive Event Listeners
Support 'passive' option on event listeners
Jul 5, 2024
Describe the bug
Most DOM events are not passive by default, but some are ( wheel, scroll, ..) .
see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#passive
And it is not consistent among major Browsers.
Should Solids JSX support explicit passive options for event listeners ?
See how React addressed this issue: facebook/react#6436 and the resolution: facebook/react#19654
see example : https://playground.solidjs.com/anonymous/79b0f65b-ac15-486e-8fba-58eebe7048ba
Your Example Website or App
https://playground.solidjs.com/anonymous/79b0f65b-ac15-486e-8fba-58eebe7048ba
Steps to Reproduce the Bug or Issue
see https://playground.solidjs.com/anonymous/79b0f65b-ac15-486e-8fba-58eebe7048ba
Expected behavior
Like
on:*
andoncapture:*
There could be a JSX syntax to specify the passive option for events. Maybe
onpassive:*
andonnotpassive: *
oronWheelNotPassive
andonScrollNotPassive
Screenshots or Videos
No response
Platform
only in Chrome AFAIK
Additional context
No response
The text was updated successfully, but these errors were encountered: