How to use the global/document.addEventListener function in global

To help you get started, we’ve selected a few global examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github notenoughneon / nekocafe / static / bundle.js View on Github external
if (model.effects) apply(model.namespace, model.effects, effects)
    })

    // send() is used to trigger actions inside
    // views, effects and subscriptions
    const send = sendAction({
      onaction: handleAction,
      onchange: onchange,
      state: initialState
    })

    // subscriptions are loaded after sendAction() is called
    // because they both need access to send() and can't
    // react to actions (read-only) - also wait on DOM to
    // be loaded
    document.addEventListener('DOMContentLoaded', function () {
      _models.forEach(function (model) {
        if (model.subscriptions) {
          assert.ok(Array.isArray(model.subscriptions), 'subs must be an arr')
          model.subscriptions.forEach(function (sub) {
            sub(send)
          })
        }
      })
    })

    // If an id is provided, the application will rehydrate
    // on the node. If no id is provided it will return
    // a tree that's ready to be appended to the DOM.
    //
    // The rootId is determined to find the application root
    // on update. Since the DOM nodes change between updates,
github shama / modal-element / index.js View on Github external
onload(overlay, function () {
      document.addEventListener('mousedown', didClickOut, false)
    }, function () {
      document.removeEventListener('mousedown', didClickOut, false)
github keplergl / kepler.gl / src / components / common / slider / mouse-event.js View on Github external
handleTouchStart = e => {
    document.addEventListener('touchend', this._touchend);
    document.addEventListener('touchmove', this._touchmove);
    this._prev = this._getTouchPosition(e);
    this._toggleMouseOver();
  };
github Raynos / graphics / input / keyboard-arrows.js View on Github external
return signal(function (next) {
        var down = {}

        document.addEventListener("keyup", function onup(ev) {
            if (ev.which in KEYS) {
                var key = KEYS[ev.which]
                down[key] = false

                next(getState())
            }
        })

        document.addEventListener("keydown", function ondown(ev) {
            if (ev.which in KEYS) {
                var key = KEYS[ev.which]
                down[key] = true

                next(getState())
            }
        })
github uber / nebula.gl / modules / main / src / lib / nebula.js View on Github external
['click', 'dblclick', 'mousemove', 'mouseup', 'mousedown'].forEach(name =>
      document.addEventListener(name, this._onMouseEvent, true)
    );
github Raynos / graphics / input / event-pool.js View on Github external
function handleChange(next) {
        document.addEventListener("keypress", function (ev) {
            var target = ev.target
            var fn = storage.get("change", target)

            if (!fn || target.type !== "text") {
                return
            }

            nextTick(fn(target.value), target)
        })

        document.addEventListener("change", function (ev) {
            var target = ev.target
            var fn = storage.get("change", target)

            if (!fn || target.type !== "checkbox") {
                return
github lukeburns / morphable / example / bundle.js View on Github external
if (Object.keys(watch).length < 1) return;
        for (var i = 0; i < mutations.length; i++) {
          if (mutations[i].attributeName === KEY_ATTR) {
            eachAttr(mutations[i], turnon, turnoff);
            continue;
          }
          eachMutation(mutations[i].removedNodes, function (index, el) {
            if (!document.documentElement.contains(el)) turnoff(index, el);
          });
          eachMutation(mutations[i].addedNodes, turnon);
        }
      });
      if (document.body) {
        beginObserve(observer);
      } else {
        document.addEventListener('DOMContentLoaded', function (event) {
          beginObserve(observer);
        });
      }
    }

    function beginObserve(observer) {
      observer.observe(document.documentElement, {
        childList: true,
        subtree: true,
        attributes: true,
        attributeOldValue: true,
        attributeFilter: [KEY_ATTR]
      });
    }

    module.exports = function onload(el, on, off, caller) {
github uber / deck.gl / examples / google-maps / event-manager.js View on Github external
_onMouseDown(event) {
    const pos = this._getMousePos(event);
    this.setState({
      didDrag: false,
      startPos: pos,
      pos,
      isFunctionKeyPressed: this._isFunctionKeyPressed(event)
    });
    this.props.onMouseDown({pos});
    document.addEventListener('mousemove', this._onMouseDrag, false);
    document.addEventListener('mouseup', this._onMouseUp, false);
  }
github Raynos / graphics / input / event-pool.js View on Github external
function handleChange(next) {
        document.addEventListener("keypress", function (ev) {
            var target = ev.target
            var fn = storage.get("change", target)

            if (!fn || target.type !== "text") {
                return
            }

            nextTick(fn(target.value), target)
        })

        document.addEventListener("change", function (ev) {
            var target = ev.target
            var fn = storage.get("change", target)

            if (!fn || target.type !== "checkbox") {
                return
            }

            nextTick(fn(target.checked), target)
        })
    }