Example #1
0
    measure: function(callback: MeasureOnSuccessCallback) {
      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.measure(
          maybeInstance.node,
          mountSafeCallback_NOT_REALLY_SAFE(this, callback),
        );
      } else {
        UIManager.measure(
          findNodeHandle(this),
          mountSafeCallback_NOT_REALLY_SAFE(this, callback),
        );
      }
    },
  _remeasureMetricsOnActivation: function() {
    const tag = this.state.touchable.responderID;
    if (tag == null) {
      return;
    }

    UIManager.measure(tag, this._handleQueryLayout);
  },
 verifyMeasureOnViewC: function() {
   UIManager.measure(C, function(a, b, width, height, x, y) {
     assertEquals(50, width);
     assertEquals(150, height);
     assertEquals(150, x);
     assertEquals(150, y);
   });
 },
Example #4
0
 const hlSub = agent.sub('highlight', ({node, name, props}) => {
   clearTimeout(_hideWait);
   UIManager.measure(node, (x, y, width, height, left, top) => {
     this.setState({
       hierarchy: [],
       inspected: {
         frame: {left, top, width, height},
         style: props ? props.style : {},
       },
     });
   });
 });
Example #5
0
 setSelection(i: number) {
   const instance = this.state.hierarchy[i];
   // if we inspect a stateless component we can't use the getPublicInstance method
   // therefore we use the internal _instance property directly.
   const publicInstance = instance['_instance'] || {};
   const source = instance['_currentElement'] && instance['_currentElement']['_source'];
   UIManager.measure(instance.getHostNode(), (x, y, width, height, left, top) => {
     this.setState({
       inspected: {
         frame: {left, top, width, height},
         style: publicInstance.props ? publicInstance.props.style : {},
         source,
       },
       selection: i,
     });
   });
 }
Example #6
0
    const hlSub = agent.sub('highlight', ({node, name, props}) => {
      clearTimeout(_hideWait);

      if (typeof node !== 'number') {
        // Fiber
        node = ReactNative.findNodeHandle(node);
      }

      UIManager.measure(node, (x, y, width, height, left, top) => {
        this.setState({
          hierarchy: [],
          inspected: {
            frame: {left, top, width, height},
            style: props ? props.style : emptyObject,
          },
        });
      });
    });
Example #7
0
    const hlSub = agent.sub('highlight', ({node, name, props}) => {
      /* $FlowFixMe(>=0.63.0 site=react_native_fb) This comment suppresses an
       * error found when Flow v0.63 was deployed. To see the error delete this
       * comment and run Flow. */
      clearTimeout(_hideWait);

      if (typeof node !== 'number') {
        // Fiber
        node = ReactNative.findNodeHandle(node);
      }

      UIManager.measure(node, (x, y, width, height, left, top) => {
        this.setState({
          hierarchy: [],
          inspected: {
            frame: {left, top, width, height},
            style: props ? props.style : {},
          },
        });
      });
    });
Example #8
0
 measure: function(callback: MeasureOnSuccessCallback) {
   UIManager.measure(
     findNumericNodeHandle(this),
     mountSafeCallback(this, callback),
   );
 },
Example #9
0
 measure(callback: MeasureOnSuccessCallback) {
   UIManager.measure(
     this._nativeTag,
     mountSafeCallback_NOT_REALLY_SAFE(this, callback),
   );
 }
 measure: function (callback) {
   UIManager.measure(findNodeHandle(this), mountSafeCallback(this, callback));
 },
Example #11
0
 measure(callback: MeasureOnSuccessCallback) {
   UIManager.measure(this._nativeTag, mountSafeCallback(this, callback));
 }
Example #12
0
 measure: callback =>
   UIManager.measure(getHostNode(fiber, findNodeHandle), callback),
 measure: function(callback: MeasureOnSuccessCallback) {
   UIManager.measure(
     ReactNative.findNodeHandle(this),
     mountSafeCallback(this, callback),
   );
 },
Example #14
0
 measure: function(callback) {
   UIManager.measure(
     ReactDOM.findDOMNode(this),
     mountSafeCallback(this, callback)
   );
 },
Example #15
0
 /**
  * Measures the on-screen location and dimensions. If successful, the callback
  * will be called asynchronously with the following arguments:
  *
  *  - x
  *  - y
  *  - width
  *  - height
  *  - pageX
  *  - pageY
  *
  * These values are not available until after natives rendering completes. If
  * you need the measurements as soon as possible, consider using the
  * [`onLayout` prop](docs/view.html#onlayout) instead.
  */
 measure(callback: MeasureOnSuccessCallback): void {
   UIManager.measure(
     findNodeHandle(this),
     mountSafeCallback_NOT_REALLY_SAFE(this, callback),
   );
 }