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.runtime.remember
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clipToBounds
|
import androidx.compose.ui.draw.clipToBounds
|
||||||
import androidx.compose.ui.draw.alpha
|
import androidx.compose.ui.graphics.graphicsLayer
|
||||||
import androidx.compose.foundation.layout.offset
|
|
||||||
import androidx.compose.ui.layout.onSizeChanged
|
import androidx.compose.ui.layout.onSizeChanged
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@ -216,8 +215,10 @@ private fun WeekRow(
|
|||||||
if (isAnchor && phase1 >= 1f) Modifier.background(MaterialTheme.colorScheme.surface)
|
if (isAnchor && phase1 >= 1f) Modifier.background(MaterialTheme.colorScheme.surface)
|
||||||
else Modifier
|
else Modifier
|
||||||
)
|
)
|
||||||
.offset(y = with(density) { yOffsetPx.toDp() })
|
.graphicsLayer {
|
||||||
.alpha(rowAlpha)
|
translationY = yOffsetPx
|
||||||
|
alpha = rowAlpha
|
||||||
|
}
|
||||||
.then(
|
.then(
|
||||||
if (weekIndex == 0 && rowHeightPx == 0) {
|
if (weekIndex == 0 && rowHeightPx == 0) {
|
||||||
Modifier.onSizeChanged { size ->
|
Modifier.onSizeChanged { size ->
|
||||||
|
|||||||
@ -720,9 +720,10 @@ private fun BottomCardArea(
|
|||||||
composeTraceEndSection()
|
composeTraceEndSection()
|
||||||
},
|
},
|
||||||
dragRangePx = dragRangePx,
|
dragRangePx = dragRangePx,
|
||||||
modifier = modifier
|
modifier = modifier.graphicsLayer {
|
||||||
.offset(y = with(density) { (slideProgress * 300).dp })
|
translationY = (slideProgress * 300).dp.toPx()
|
||||||
.alpha(1f - slideProgress)
|
alpha = 1f - slideProgress
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user