How to use the metal-dom.on function in metal-dom

To help you get started, we’ve selected a few metal-dom 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 deprecate / metal-position / test / Position.js View on Github external
var nextScrollTick = function(fn, opt_el) {
	var handler = dom.on(opt_el || document, 'scroll', function() {
		fn();
		handler.removeListener();
	});
};
github LiferayCloud / marble / packages / marble-autocomplete / src / Autocomplete.js View on Github external
attached() {
    super.attached();
    this.setAriaAttributes_();
    this.eventHandler_.add(
      dom.on(this.inputElement, 'focus', this.handleInputFocus_.bind(this))
    );
    this.eventHandler_.add(
      dom.on(document, 'click', this.handleDocClick_.bind(this))
    );
    this.eventHandler_.add(
      dom.on(
        window,
        'resize',
        debounce(this.handleWindowResize_.bind(this), 100)
      )
    );
    this.eventHandler_.add(
      dom.on(this.inputElement, 'keydown', this.handleKeyDown_.bind(this))
    );
    this.eventHandler_.add(
      this.getList().on('rendered', this.handleListRender_.bind(this))
    );
    if (this.visible) {
      this.align();
    }
  }
github liferay / sennajs.com / src / partials / ElectricApi.js View on Github external
maxResults: 4,
			project,
			input: document.querySelector('input[name="query"]')
		});

		this.dropdowns_ = new Toggler({
			content: '.version-dropdown .dropdown-menu',
			header: '.version-dropdown .btn'
		});

		this.toggler_ = new Toggler({
			content: '.sidebar-toggler-content',
			header: '.sidebar-header'
		});

		this.docClickHandler_ = dom.on(document, 'click', this.handleDocClick_.bind(this));
	}
github LiferayCloud / marble / packages / marble-autocomplete / src / AutocompleteBase.js View on Github external
attached() {
    if (this.inputElement) {
      this.eventHandler_.add(
        dom.on(this.inputElement, 'input', this.handleUserInput_.bind(this))
      );
    }
  }
github liferay / senna.js / src / app / App.js View on Github external
this.surfaces = {};

		/**
		 * When set to true, moves the scroll position after popstate, or to the
		 * top of the viewport for new navigation. If false, the browser will
		 * take care of scroll restoration.
		 * @type {!boolean}
		 * @default true
		 * @protected
		 */
		this.updateScrollPosition = true;

		this.appEventHandlers_ = new EventHandler();

		this.appEventHandlers_.add(
			on(globals.window, 'scroll', debounce(this.onScroll_.bind(this), 100)),
			on(globals.window, 'load', this.onLoad_.bind(this)),
			on(globals.window, 'popstate', this.onPopstate_.bind(this))
		);

		this.on('startNavigate', this.onStartNavigate_);
		this.on('beforeNavigate', this.onBeforeNavigate_);
		this.on('beforeNavigate', this.onBeforeNavigateDefault_, true);
		this.on('beforeUnload', this.onBeforeUnloadDefault_);

		this.setLinkSelector(this.linkSelector);
		this.setFormSelector(this.formSelector);

		this.maybeOverloadBeforeUnload_();
	}
github LiferayCloud / marble / packages / marble-autocomplete / src / Autocomplete.js View on Github external
this.setAriaAttributes_();
    this.eventHandler_.add(
      dom.on(this.inputElement, 'focus', this.handleInputFocus_.bind(this))
    );
    this.eventHandler_.add(
      dom.on(document, 'click', this.handleDocClick_.bind(this))
    );
    this.eventHandler_.add(
      dom.on(
        window,
        'resize',
        debounce(this.handleWindowResize_.bind(this), 100)
      )
    );
    this.eventHandler_.add(
      dom.on(this.inputElement, 'keydown', this.handleKeyDown_.bind(this))
    );
    this.eventHandler_.add(
      this.getList().on('rendered', this.handleListRender_.bind(this))
    );
    if (this.visible) {
      this.align();
    }
  }
github liferay / senna.js / src / app / App.js View on Github external
/**
		 * When set to true, moves the scroll position after popstate, or to the
		 * top of the viewport for new navigation. If false, the browser will
		 * take care of scroll restoration.
		 * @type {!boolean}
		 * @default true
		 * @protected
		 */
		this.updateScrollPosition = true;

		this.appEventHandlers_ = new EventHandler();

		this.appEventHandlers_.add(
			on(globals.window, 'scroll', debounce(this.onScroll_.bind(this), 100)),
			on(globals.window, 'load', this.onLoad_.bind(this)),
			on(globals.window, 'popstate', this.onPopstate_.bind(this))
		);

		this.on('startNavigate', this.onStartNavigate_);
		this.on('beforeNavigate', this.onBeforeNavigate_);
		this.on('beforeNavigate', this.onBeforeNavigateDefault_, true);
		this.on('beforeUnload', this.onBeforeUnloadDefault_);

		this.setLinkSelector(this.linkSelector);
		this.setFormSelector(this.formSelector);

		this.maybeOverloadBeforeUnload_();
	}
github LiferayCloud / marble / packages / marble-autocomplete / src / Autocomplete.js View on Github external
attached() {
    super.attached();
    this.setAriaAttributes_();
    this.eventHandler_.add(
      dom.on(this.inputElement, 'focus', this.handleInputFocus_.bind(this))
    );
    this.eventHandler_.add(
      dom.on(document, 'click', this.handleDocClick_.bind(this))
    );
    this.eventHandler_.add(
      dom.on(
        window,
        'resize',
        debounce(this.handleWindowResize_.bind(this), 100)
      )
    );
    this.eventHandler_.add(
      dom.on(this.inputElement, 'keydown', this.handleKeyDown_.bind(this))
    );
    this.eventHandler_.add(
      this.getList().on('rendered', this.handleListRender_.bind(this))
github LiferayCloud / marble / packages / marble-autocomplete / src / Autocomplete.js View on Github external
attached() {
    super.attached();
    this.setAriaAttributes_();
    this.eventHandler_.add(
      dom.on(this.inputElement, 'focus', this.handleInputFocus_.bind(this))
    );
    this.eventHandler_.add(
      dom.on(document, 'click', this.handleDocClick_.bind(this))
    );
    this.eventHandler_.add(
      dom.on(
        window,
        'resize',
        debounce(this.handleWindowResize_.bind(this), 100)
      )
    );
    this.eventHandler_.add(
      dom.on(this.inputElement, 'keydown', this.handleKeyDown_.bind(this))
    );
    this.eventHandler_.add(
      this.getList().on('rendered', this.handleListRender_.bind(this))
    );
    if (this.visible) {
      this.align();