Beispiel #1
0
    measureInWindow: function(callback: MeasureInWindowOnSuccessCallback) {
      let maybeInstance;

      // Fiber errors if findNodeHandle is called for an umounted component.
      // Tests using ReactTestRenderer will trigger this case indirectly.
      // Mimicking stack behavior, we should silently ignore this case.
      // TODO Fix ReactTestRenderer so we can remove this try/catch.
      try {
        maybeInstance = findHostInstance(this);
      } catch (error) {}

      // If there is no host component beneath this we should fail silently.
      // This is not an error; it could mean a class component rendered null.
      if (maybeInstance == null) {
        return;
      }

      if (maybeInstance.canonical) {
        // We can't call FabricUIManager here because it won't be loaded in paper
        // at initialization time. See https://github.com/facebook/react/pull/15490
        // for more info.
        nativeFabricUIManager.measureInWindow(
          maybeInstance.node,
          mountSafeCallback_NOT_REALLY_SAFE(this, callback),
        );
      } else {
        UIManager.measureInWindow(
          findNodeHandle(this),
          mountSafeCallback_NOT_REALLY_SAFE(this, callback),
        );
      }
    },
Beispiel #2
0
 measureInWindow: function(callback: MeasureInWindowOnSuccessCallback) {
   UIManager.measureInWindow(
     findNumericNodeHandle(this),
     mountSafeCallback(this, callback),
   );
 },
 measureInWindow(callback: MeasureInWindowOnSuccessCallback) {
   UIManager.measureInWindow(
     this._nativeTag,
     mountSafeCallback_NOT_REALLY_SAFE(this, callback),
   );
 }
 measureInWindow: function (callback) {
   UIManager.measureInWindow(findNodeHandle(this), mountSafeCallback(this, callback));
 },
 /**
  * Measures the on-screen location and dimensions. Even if the React Native
  * root view is embedded within another native view, this method will give you
  * the absolute coordinates measured from the window. If successful, the
  * callback will be called asynchronously with the following arguments:
  *
  *  - x
  *  - y
  *  - width
  *  - height
  *
  * These values are not available until after natives rendering completes.
  */
 measureInWindow(callback: MeasureInWindowOnSuccessCallback): void {
   UIManager.measureInWindow(
     findNodeHandle(this),
     mountSafeCallback_NOT_REALLY_SAFE(this, callback),
   );
 }