gm0t / react-sticky-el

MIT License
256 stars 47 forks source link

min-height is unnecessarily set in holder when sticky has dynamic height #73

Open Hatt0ri opened 2 years ago

Hatt0ri commented 2 years ago

I have dynamically changing height in MUI accordion. After collapsing it, holder keeps min-height and thus height can't update properly before scrolling. I changed the code in a way that holderStyles is not getting styles when isFixed false. In my opinion min-height is not needed there when not fixed. My solution below works for me. What do you think?

changed lines file render-props-version

 holderStyles: isFixed ? {
          minHeight: minHeight + "px"
        } : {}

and

file render-props-version

 var newState = {
        isFixed: isFixed,
        height: wrapperRect.height,
        holderStyles: isFixed ? {
          minHeight: minHeight + "px"
        } : {},
        wrapperStyles: isFixed ? _extends({}, iosRenderingFixStyles, buildStickyStyle(mode, _this.props, {
          boundaryTop: mode === 'bottom' ? boundaryRect.top : 0,
          boundaryBottom: mode === 'top' ? boundaryRect.bottom : 0,
          top: mode === 'top' ? scrollRect.top - (offsets ? offsets.top : 0) : 0,
          bottom: mode === 'bottom' ? scrollRect.bottom - (offsets ? offsets.bottom : 0) : 0,
          width: holderRect.width,
          height: wrapperRect.height
        })) : iosRenderingFixStyles
      };