Skip to content

Commit

Permalink
layoutdsl: migrate size.kt to statev2
Browse files Browse the repository at this point in the history
Source-Commit: 220d821dd9b2e90f182eea3c18907f4474797bb8
  • Loading branch information
Sychic authored and Johni0702 committed Aug 12, 2024
1 parent 84438d1 commit e076bf8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import gg.essential.elementa.constraints.*
import gg.essential.elementa.constraints.animation.*
import gg.essential.elementa.dsl.*
import gg.essential.elementa.common.constraints.FillConstraintIncludingPadding
import gg.essential.elementa.common.onSetValueAndNow
import gg.essential.elementa.state.v2.State
import gg.essential.elementa.state.v2.effect
import gg.essential.elementa.state.v2.stateOf
import gg.essential.elementa.util.hasWindow

Expand Down Expand Up @@ -95,7 +95,9 @@ private class AnimateWidthModifier(private val newWidth: State<() -> WidthConstr
}
}

val removeListenerCallback = newWidth.onSetValueAndNow(component) { animate(it()) }
val removeListenerCallback = effect(component) {
animate(newWidth()())
}

return {
removeListenerCallback()
Expand All @@ -118,7 +120,9 @@ private class AnimateHeightModifier(private val newHeight: State<() -> HeightCon
}
}

val removeListenerCallback = newHeight.onSetValueAndNow(component) { animate(it()) }
val removeListenerCallback = effect(component) {
animate(newHeight()())
}

return {
removeListenerCallback()
Expand Down

0 comments on commit e076bf8

Please sign in to comment.