Beispiel #1
0
        ReactUpdates.batchedUpdates(() => {
            for (let i = 0; i < intersections.length; ++i) {
                const intersection = intersections[i];

                if (event.isDefaultPrevented() || event.isPropagationStopped()) {
                    return;
                }

                const object = intersection.object;

                React3.eventDispatcher.dispatchEvent(object, callbackName, event, intersection);
            }
        });
Beispiel #2
0
        ReactUpdates.batchedUpdates(() => {
            const {
                event,
                intersections,
            } = this._intersectAndDispatch(callbackName, mouseEvent);

            if (!(event.isDefaultPrevented() || event.isPropagationStopped())) {
                if (this._intersectionsForClick === null) {
                    return;
                }

                // intersect current intersections with the intersections for click
                //   call xzibit ASAP we have a good one son
                //     it wasn't that good

                const intersectionUUIDMap = this._intersectionsForClick.reduce((map, intersection) => {
                    map[intersection.object.uuid] = intersection;

                    return map;
                }, {});

                for (let i = 0; i < intersections.length; ++i) {
                    if (event.isDefaultPrevented() || event.isPropagationStopped()) {
                        return;
                    }

                    const intersection = intersections[i];

                    const object = intersection.object;

                    const uuid = object.uuid;

                    if (intersectionUUIDMap[uuid]) {
                        // oh boy oh boy here we go, we got a clicker

                        React3.eventDispatcher
                        .dispatchEvent(object, 'onClick',
                                       this._createSyntheticMouseEvent('click', event), intersection);
                    }
                }
            }
        });
Beispiel #3
0
    _updateEnterLeave() {
        const intersections = this._getIntersections(this._mouse);

        const hoverMapToUpdate = {
            ...this._hoverObjectMap,
        };

        const mouseEnterEvent = this._createSyntheticMouseEvent('mouseEnter', {
            target: this._container,
            clientX: this._mouse.x,
            clientY: this._mouse.y,
        });

        // find first intersection that does not ignore pointer events
        for (let depth = 0; depth < intersections.length; ++depth) {
            const intersection = intersections[depth];
            const object = intersection.object;

            if (object.userData && object.userData.ignorePointerEvents) {
                continue;
            }

            const uuid = object.uuid;

            if (this._hoverObjectMap[uuid]) {
                delete hoverMapToUpdate[uuid];

                // just update that intersection
                this._hoverObjectMap[uuid].intersection = intersection;
            } else {
                this._hoverObjectMap[uuid] = {
                    object,
                    intersection,
                };

                if (!(mouseEnterEvent.isDefaultPrevented() || mouseEnterEvent.isPropagationStopped())) {
                    React3.eventDispatcher.dispatchEvent(object, 'onMouseEnter',
                                                         mouseEnterEvent, intersection, depth);
                }
            }

            // we have found the first solid intersection, don't go further
            break;
        }

        const mouseLeaveEvent = this._createSyntheticMouseEvent('mouseLeave', {
            target: this._container,
            clientX: this._mouse.x,
            clientY: this._mouse.y,
        });

        // delete all unseen uuids in hover map
        const unseenUUIDs = Object.keys(hoverMapToUpdate);

        for (let i = 0; i < unseenUUIDs.length; ++i) {
            const uuid = unseenUUIDs[i];

            if (!(mouseLeaveEvent.isDefaultPrevented() || mouseLeaveEvent.isPropagationStopped())) {
                React3.eventDispatcher.dispatchEvent(this._hoverObjectMap[uuid].object,
                                                     'onMouseLeave', mouseLeaveEvent);
            }

            delete this._hoverObjectMap[uuid];
        }
    }
Beispiel #4
0
 dispatchEvent (object, name, event, intersection, depth) {
   if (object.parent) {
     this.dispatchEvent(object.parent, name, event, intersection, depth)
   }
   React3.eventDispatcher.dispatchEvent(object, name, event, intersection, depth)
 }