Example #1
0
    return function () {
      const execute = function () {
        if (editor.selection) {
          reposition(findFrontMostMatch(editor.selection.getNode()), show);
        }
      };

      Delay.requestAnimationFrame(execute);
    };
    self.on('mouseenter click', function (e) {
      if (e.control === self) {
        if (!settings.menu && e.type === 'click') {
          self.fire('select');

          // Edge will crash if you stress it see #2660
          Delay.requestAnimationFrame(function () {
            self.parent().hideAll();
          });
        } else {
          self.showMenu();

          if (e.aria) {
            self.menu.focus(true);
          }
        }
      }
    });
      if (!dirtyCtrls[parent._id]) {
        dirtyCtrls[parent._id] = parent;
      }

      if (!animationFrameRequested) {
        animationFrameRequested = true;

        Delay.requestAnimationFrame(function () {
          let id, ctrl;

          animationFrameRequested = false;

          for (id in dirtyCtrls) {
            ctrl = dirtyCtrls[id];

            if (ctrl.state.get('rendered')) {
              ctrl.reflow();
            }
          }

          dirtyCtrls = {};
        }, document.body);
      }
    }
  },

  /**
   * Removes the specified control from the automatic reflow. This will happen when for example the user
   * manually triggers a reflow.
   *
 suite.asyncTest('requestAnimationFrame', function (_, done) {
   Delay.requestAnimationFrame(function () {
     ok(true, 'requestAnimationFrame was executed.');
     done();
   });
 });