You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2019/04/19 04:05:12 UTC

[GitHub] [incubator-weex] YorkShen commented on a change in pull request #2321: [core] fix flex-end in row-reverse

YorkShen commented on a change in pull request #2321: [core] fix flex-end in row-reverse
URL: https://github.com/apache/incubator-weex/pull/2321#discussion_r276897126
 
 

 ##########
 File path: weex_core/Source/core/layout/layout.cpp
 ##########
 @@ -740,46 +742,66 @@ namespace WeexCore {
     }
   }
 
+  void WXCoreLayoutNode::layoutFlexlineHorizontal(const bool isRTL,
+                                                  const float width,
+                                                  const WXCoreFlexLine *const flexLine,
+                                                  float &childLeft,
+                                                  float &childRight,
+                                                  float &spaceBetweenItem) const {
+      Index visibleCount, visibleItem;
+      float denominator;
+      switch (mCssStyle->mJustifyContent) {
+          case kJustifyFlexEnd:
+              if (isRTL) {
+                  childLeft = getPaddingLeft() + getBorderWidthLeft();
+                  childRight = flexLine->mMainSize + getPaddingLeft() + getBorderWidthLeft();
+              } else {
+                  childLeft = width - flexLine->mMainSize - getPaddingRight() - getBorderWidthRight();
+                  childRight = width - getPaddingLeft() - getBorderWidthLeft();
+              }
+              
+              break;
+          case kJustifyCenter:
+              childLeft = (width - flexLine->mMainSize - mCssStyle->sumPaddingBorderOfEdge(kRight)
+                              + mCssStyle->sumPaddingBorderOfEdge(kLeft)) / 2;
+              childRight = childLeft + flexLine->mMainSize;
+              break;
+          case kJustifySpaceAround:
+              visibleCount = flexLine->mItemCount;
+              if (visibleCount != 0) {
+                  spaceBetweenItem =
+                  (width - flexLine->mMainSize - sumPaddingBorderAlongAxis(this, true)) / visibleCount;
+              }
+              childLeft = getPaddingLeft() + getBorderWidthLeft() + spaceBetweenItem / 2.f;
+              childRight = width - getPaddingRight() - getBorderWidthRight() - spaceBetweenItem / 2.f;
+              break;
+          case kJustifySpaceBetween:
+              childLeft = getPaddingLeft() + getBorderWidthLeft();
+              visibleItem = flexLine->mItemCount;
+              denominator = visibleItem != 1 ? visibleItem - 1 : 1.f;
+              spaceBetweenItem =
+              (width - flexLine->mMainSize - sumPaddingBorderAlongAxis(this, true)) / denominator;
+              childRight = width - getPaddingRight() - getBorderWidthRight();
+              break;
+          case kJustifyFlexStart:
+          default:
+              if (isRTL) {
+                  childLeft = width - flexLine->mMainSize - getPaddingRight() - getBorderWidthRight();
+                  childRight = width - getPaddingRight() - getBorderWidthRight();
 
 Review comment:
   I think this line should change to  `childRight = width - getPaddingLeft() - getBorderWidthLeft();`,  which is the same as kJustifyFlexEnd case with LTR.
   
   The reason `childRight = width - getPaddingLeft() - getBorderWidthLeft();` works is due to the following equation:
   
       width = flexLine->mMainSize + getPaddingLeft() + getBorderWidthLeft() + getPaddingRight() + getBorderWidthRight()
   
   Then we have
   
       childRight = getPaddingRight() + getBorderWidthRight()+ flexLine->mMainSize  =  width - getPaddingLeft() - getBorderWidthLeft();

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services