How to use the @polymer/polymer/lib/utils/async.js.microTask.run function in @polymer/polymer

To help you get started, we’ve selected a few @polymer/polymer 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 elmsln / lrnwebcomponents / elements / haxcms-elements / lib / core / themes / haxcms-legacy-player.js View on Github external
_activeItemContentChanged(newValue, oldValue) {
    if (newValue) {
      var html = newValue;
      // only append if not empty
      if (html !== null) {
        wipeSlot(this, "*");
        html = encapScript(newValue);
        // insert the content as quickly as possible, then work on the dynamic imports
        microTask.run(() => {
          setTimeout(() => {
            let frag = document.createRange().createContextualFragment(html);
            this.appendChild(frag);
            const evt = new CustomEvent(
              "json-outline-schema-active-body-changed",
              {
                bubbles: true,
                composed: true,
                cancelable: false,
                detail: { html }
              }
            );
          }, 5);
        });
        // if there are, dynamically import them
        if (varExists(this.manifest, "metadata.node.dynamicElementLoader")) {
github elmsln / lrnwebcomponents / elements / eco-json-schema-form / lib / eco-json-schema-file.js View on Github external
_retryUpload(e) {
    e.model.set("item.error", false);
    e.model.set("item.progress", 0);
    // The async helps give visual feedback of a retry occurring, even though it's less efficient.
    var self = this;
    microTask.run(() => {
      self.uploadFile(e.model.__data__.item);
    });
  }
github elmsln / lrnwebcomponents / elements / haxcms-elements / lib / ui-components / active-item / site-render-item.js View on Github external
_itemContentChanged(newValue, oldValue) {
    if (newValue) {
      var html = newValue;
      // only append if not empty
      if (html !== null) {
        html = encapScript(newValue);
        wipeSlot(this, "*");
        // insert the content as quickly as possible, then work on the dynamic imports
        microTask.run(() => {
          setTimeout(() => {
            let frag = document.createRange().createContextualFragment(html);
            this.appendChild(frag);
          }, 5);
        });
        // if there are, dynamically import them
        if (varExists(this.manifest, "metadata.node.dynamicElementLoader")) {
          let tagsFound = findTagsInHTML(html);
          const basePath = this.pathFromUrl(
            decodeURIComponent(import.meta.url)
          );
          for (var i in tagsFound) {
            const tagName = tagsFound[i];
            if (
              this.manifest.metadata.node.dynamicElementLoader[tagName] &&
              !window.customElements.get(tagName)
github nuxeo / nuxeo-elements / ui / nuxeo-data-table / data-table-cell.js View on Github external
_columnPathChanged(instance, column) {
      if (!instance) {
        return;
      }
      // sometimes instance isn't ready to be notified yet and throws an error.
      microTask.run(() => {
        // TODO: hack to avoid: https://github.com/Polymer/polymer/issues/3307
        this._parentProps = this._parentProps || {};
        instance.notifyPath(column.path, column.value);
      });
    }
  }
github nuxeo / nuxeo-elements / ui / widgets / nuxeo-tooltip.js View on Github external
// create a paper tooltip and append to body
        this._tooltip = document.createElement('paper-tooltip');
        document.body.appendChild(this._tooltip);
        // clone content in  and append to paper-tooltip body
        this.$.content.assignedNodes().forEach((node) => {
          this._tooltip.appendChild(node.cloneNode(true));
        });
        // set manual mode to avoid setting extra listeners in paper-tooltip
        this._tooltip.manualMode = true;
        // configure tooltip properties and show
        this._tooltip._target = this._target;
        this._tooltip.animationDelay = this.animationDelay;
        this._tooltip.offset = this.offset;
        this._tooltip.position = this.position;
        this._tooltip.fitToVisibleBounds = true;
        microTask.run(() => {
          this._tooltip.show();
        });
      }
    }
github Polymer / shop / src / components / shop-tabs-overlay.js View on Github external
let fromOpacity = oldTarget ? 1 : 0;
    let toOpacity = newTarget ? 1 : 0;

    flush();
    let thisRect = this.getBoundingClientRect();
    let thisStyle = window.getComputedStyle(this);
    let fromRect = from.getBoundingClientRect();
    let toRect = to.getBoundingClientRect();

    if (toRect.top === 0 && toRect.right === 0 &&
        toRect.bottom === 0 && toRect.left === 0 &&
        toRect.width === 0 && toRect.height === 0) {
      this.style.transitionProperty = 'none';
      this.style.opacity = toOpacity;
      this._transitionsInFlight = [];
      microTask.run(this._moveComplete.bind(this))
      return;
    } else {
      this.style.transitionProperty = '';
    }

    let top = parseFloat(thisStyle.top || '0') + (fromRect.top - thisRect.top);
    let right = parseFloat(thisStyle.right || '0') - (fromRect.right - thisRect.right);
    let bottom = parseFloat(thisStyle.bottom || '0') - (fromRect.bottom - thisRect.bottom);
    let left = parseFloat(thisStyle.left || '0') + (fromRect.left - thisRect.left);

    this.style.transitionDuration = '0s';
    this.style.transitionDelay = '0s';
    let startValues = [
      this.style.top = top + 'px',
      this.style.right = right + 'px',
      this.style.bottom = bottom + 'px',
github elmsln / lrnwebcomponents / elements / paper-fab-transitions / lib / paper-fab-morph.js View on Github external
_morphClose() {
    var fab = this._fab;
    var content = this._content;

    var contentRect = fab.getBoundingClientRect();
    var morpher = this.$.morpher;
    var ms = morpher.style;

    morpher.style.display = "block";

    microTask.run(() => {
      var fabRect = fab.getBoundingClientRect();
      ms.top = fabRect.top + "px";
      ms.left = fabRect.left + "px";
      ms.width = fabRect.width + "px";
      ms.height = fabRect.height + "px";
      ms.borderRadius = "50%";

      microTask.run(() => {
        morpher.style.display = "none";
        fab.style.visibility = "visible";
      });
    });
  }
}