Skip to content

Instantly share code, notes, and snippets.

@vasnakos
vasnakos / ShadowDOMRetargetEvents
Created October 9, 2024 13:05
This function is designed to address issues with event handling in React 16 when using a Shadow DOM. React 16's synthetic event system does not work well with Shadow DOM due to limitations in how events are retargeted. This function "retargets" events that occur within a shadow DOM, making them compatible with React's synthetic event system by e…
/**
* Retargets DOM events within a Shadow DOM to ensure they are correctly recognized
* by React 16's synthetic event system. This is necessary because React 16 does not
* natively handle events from within a Shadow DOM, leading to issues with event propagation
* and target recognition.
*
* @param {ShadowRoot} shadowRoot - The root of the Shadow DOM where event retargeting should be applied.
*/
function retargetEvents(shadowRoot) {
// List of all event types to listen for within the Shadow DOM.
@vasnakos
vasnakos / MeshReflectorMaterial.js
Created July 21, 2023 13:50 — forked from 0beqz/MeshReflectorMaterial.js
ES5 MeshReflectorMaterial.js
// original implementation is from https://github.com/pmndrs/drei
const {
DepthFormat, DepthTexture, LinearFilter, Matrix4, MeshStandardMaterial,
PerspectiveCamera, Plane, UnsignedShortType, Vector3, Vector4, WebGLRenderTarget
} = THREE
class MeshReflectorMaterial extends MeshStandardMaterial {
constructor(renderer, camera, scene, object, {
mixBlur = 0,