perf(ui): defer translationY and alpha to graphicsLayer draw phase during animations
This commit is contained in:
parent
fc2f2065df
commit
ac186ed49a
@ -15,8 +15,7 @@ import androidx.compose.runtime.produceState
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clipToBounds
|
||||
import androidx.compose.ui.draw.alpha
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.unit.dp
|
||||
@ -216,8 +215,10 @@ private fun WeekRow(
|
||||
if (isAnchor && phase1 >= 1f) Modifier.background(MaterialTheme.colorScheme.surface)
|
||||
else Modifier
|
||||
)
|
||||
.offset(y = with(density) { yOffsetPx.toDp() })
|
||||
.alpha(rowAlpha)
|
||||
.graphicsLayer {
|
||||
translationY = yOffsetPx
|
||||
alpha = rowAlpha
|
||||
}
|
||||
.then(
|
||||
if (weekIndex == 0 && rowHeightPx == 0) {
|
||||
Modifier.onSizeChanged { size ->
|
||||
|
||||
@ -720,9 +720,10 @@ private fun BottomCardArea(
|
||||
composeTraceEndSection()
|
||||
},
|
||||
dragRangePx = dragRangePx,
|
||||
modifier = modifier
|
||||
.offset(y = with(density) { (slideProgress * 300).dp })
|
||||
.alpha(1f - slideProgress)
|
||||
modifier = modifier.graphicsLayer {
|
||||
translationY = (slideProgress * 300).dp.toPx()
|
||||
alpha = 1f - slideProgress
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user