flexboxobjc_deprecated icon indicating copy to clipboard operation
flexboxobjc_deprecated copied to clipboard

Why FLEXBoxNode not use minDimensions and maxDimensions

Open xiekw2010 opened this issue 9 years ago • 1 comments

In The FLEXBoxNode.m

  • (void)setMinDimensions:(CGSize)size { _minDimensions = size; // _node->style.minDimensions[CSS_WIDTH] = size.width; // _node->style.minDimensions[CSS_HEIGHT] = size.height; }
  • (void)setMaxDimensions:(CGSize)size { _maxDimensions = size; // _node->style.maxDimensions[CSS_WIDTH] = size.width; // _node->style.maxDimensions[CSS_HEIGHT] = size.height; }

The staff is not working here

xiekw2010 avatar Jul 02 '15 07:07 xiekw2010

@xiekw2010 In fact, these two properties to be used in another place. and it's work.

- (CGSize)flexComputeSize:(CGSize)bounds
{
    if (!CGSizeEqualToSize(self.flexFixedSize, CGSizeZero))
        return self.flexFixedSize;

    bounds.height = isnan(bounds.height) ? FLT_MAX : bounds.height;
    bounds.width = isnan(bounds.width) ? FLT_MAX : bounds.width;

    CGSize size = CGSizeZero;

    if (self.sizeThatFitsBlock != nil) {
        size = self.sizeThatFitsBlock(bounds);
    } else {
         size = [self sizeThatFits:bounds];
    }

    CGSize max = self.flexMaximumSize;
    if (!CGSizeEqualToSize(max, CGSizeZero) || !CGSizeEqualToSize(max, (CGSize){FLT_MAX, FLT_MAX})) {
        size.height = !isnan(max.height) && fabs(max.height) > FLT_EPSILON  && size.height > max.height ? max.height : size.height;
        size.width = !isnan(max.width) && fabs(max.width) > FLT_EPSILON  && size.width > max.width ? max.width : size.width;
    }

    CGSize min = self.flexMinimumSize;
    if (!CGSizeEqualToSize(min, CGSizeZero) || !CGSizeEqualToSize(max, (CGSize){FLT_MIN, FLT_MIN})) {
        size.height = !isnan(min.height) && fabs(min.height) > FLT_EPSILON && size.height < min.height ? min.height : size.height;
        size.width = !isnan(min.width) && fabs(min.width) > FLT_EPSILON && size.width < min.width ? min.width : size.width;
    }

    return size;
}

chenyihu avatar Jul 06 '15 01:07 chenyihu