Skip to content

Commit

Permalink
BlTransformAnimation: calculate from and to matrices only on first loop
Browse files Browse the repository at this point in the history
Fix #188
Pair-programmed with Pablo last week
  • Loading branch information
tinchodias committed Dec 1, 2022
1 parent 7e8f3cb commit f37644c
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions src/Bloc-Animation/BlTransformAnimation.class.st
Expand Up @@ -68,26 +68,25 @@ BlTransformAnimation >> initStart [

super initStart.

isAbsolute
ifTrue: [ elementTransformation := elementTransformation asCachedTransformation ]
ifFalse: [
| aCompositeTransformation |
aCompositeTransformation :=
BlElementCompositeTransformation new
add: self target transformation asElementTransformation;
add: elementTransformation;
yourself.
elementTransformation := aCompositeTransformation asCachedTransformation ].
isAbsolute ifFalse: [
elementTransformation :=
BlElementCompositeTransformation new
add: self target transformation asElementTransformation;
add: elementTransformation asElementTransformation;
yourself ].
elementTransformation := elementTransformation asCachedTransformation.

"matrix depends on computed layout bounds, we should manually trigger layout recomputation"
self target space isLayoutRequested ifTrue: [
self target space doLayout ].

elementTransformation boundingRectangle:
self target bounds inLocal asRectangle.

fromMatrix := self target transformation matrix.
toMatrix := elementTransformation matrix
"Calculate matrix only on start of first loop"
fromMatrix ifNil: [
fromMatrix := self target transformation matrix copy.
toMatrix := elementTransformation matrix ]
]

{ #category : #initialization }
Expand Down Expand Up @@ -118,13 +117,8 @@ BlTransformAnimation >> transformation: aBlElementTransformation [
]

{ #category : #pulse }
BlTransformAnimation >> valueForStep: aDelta [
"we should recompute destination matrix every step because transformation origins may have changed"

toMatrix := elementTransformation
boundingRectangle: self target bounds inLocal asRectangle;
matrix.
BlTransformAnimation >> valueForStep: aNumber [

^ BlElementAbsoluteTransformation matrix:
(fromMatrix interpolate: aDelta to: toMatrix)
(fromMatrix interpolate: aNumber to: toMatrix)
]

0 comments on commit f37644c

Please sign in to comment.