Permalink
Browse files

Expose method to set custom baseline function

Summary:
<!--
Thank you for sending the PR! We appreciate you spending the time to work on these changes.

Help us understand your motivation by explaining why you decided to make this change.

You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html

Happy contributing!

-->

I was trying to typeset mathematical equations in react native. When typesetting fractions, baseline of the fraction must be aligned with the baseline of others. The baseline of fraction will vary based on size of numerator and denominator.

![image](https://user-images.githubusercontent.com/31202232/29577330-a22b45ee-8788-11e7-9cc5-04a72bcc1180.png)

 In yoga, we can set custom baseline function using `YogaNode.setBaselineFunction` method. If this method is exposed in `ReactShadowNode` class, it will be easy to create custom native UI modules which requires setting custom baseline.
Closes #15605

Differential Revision: D5686876

Pulled By: shergin

fbshipit-source-id: 34d797a7ea27d5c1b9f6b9c36e469cdca3883aec
  • Loading branch information...
rsreejithkrishnan authored and facebook-github-bot committed Aug 23, 2017
1 parent ad4aee7 commit 9c2caaac3e0a0f932ff67e4e80f90b6c5626b56f
Showing with 5 additions and 0 deletions.
  1. +5 −0 ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java
@@ -22,6 +22,7 @@
import com.facebook.yoga.YogaDirection;
import com.facebook.yoga.YogaFlexDirection;
import com.facebook.yoga.YogaJustify;
import com.facebook.yoga.YogaBaselineFunction;
import com.facebook.yoga.YogaMeasureFunction;
import com.facebook.yoga.YogaNode;
import com.facebook.yoga.YogaOverflow;
@@ -782,6 +783,10 @@ public void setShouldNotifyOnLayout(boolean shouldNotifyOnLayout) {
mShouldNotifyOnLayout = shouldNotifyOnLayout;
}
public void setBaselineFunction(YogaBaselineFunction baselineFunction) {
mYogaNode.setBaselineFunction(baselineFunction);
}
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
if ((measureFunction == null ^ mYogaNode.isMeasureDefined()) &&
getChildCount() != 0) {

0 comments on commit 9c2caaa

Please sign in to comment.