mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-29 09:52:03 +00:00
CPAnimationContext: Finish frame updaters before the final frame
A frame animation gives a periodic frame updater to each animated subview with custom layout or drawing. Each update writes the current frame of the CSS animation into the view. The updater stopped only when the animated view itself needed one, so such a subview kept a frame from between the start and the end of the animation, and an update could still run after the animation ended. The animated view's completion then resized the subview from that frame. After a split view item expanded, a scroll view in it was wider than the item and its row views kept a width of a few points. The animated view's completion now finishes the updater: it stops the updater and gives each updated view the frame it had when the animation started, before the final frame is set. The completion of custom-drawn subviews, which stopped the updater too early, is removed.
This commit is contained in:
1 parent
7650ff6b12
commit
309b7cda97
2 files changed
+46
-13
No files matched your search
@@ -140,8 +140,21 @@ var _CPAnimationContextStack = nil,
|
||||
|
||||
var completionFunction = function()
|
||||
{
|
||||
if (needsPeriodicFrameUpdates)
|
||||
[animatorClass stopUpdaterWithIdentifier:objectId];
|
||||
/*
|
||||
The frame updater of the animation stops before the animated view takes its final
|
||||
frame, and gives back to each view it updated the frame that view had when the
|
||||
animation started. The completion then sets the final frame from a state that
|
||||
matches the start, so autoresizing and layout give the subviews their final frames.
|
||||
|
||||
2026-11-24: the updater stopped only when the animated view itself needed periodic
|
||||
updates. A subview that needed them, such as a scroll view, kept the frame of the
|
||||
last update, which lies between the start and the end; the updater could also run
|
||||
once more after the completion. The completion then resized the subview from that
|
||||
frame: after a split view item expanded, People's sidebar scroll view was wider
|
||||
than the item, its row views kept a width of a few points, and the selection and
|
||||
the badges were drawn cut off.
|
||||
*/
|
||||
[animatorClass _finishFrameUpdaterWithIdentifier:objectId];
|
||||
|
||||
if (animationCompletion)
|
||||
animationCompletion();
|
||||
@@ -330,7 +343,8 @@ var _CPAnimationContextStack = nil,
|
||||
/*
|
||||
A subview takes its final frame from the completion of the animated view, which
|
||||
sets that view's frame and so resizes or lays out its subviews. The subview's
|
||||
own animation changes only what the browser shows.
|
||||
own animation changes only what the browser shows, and the completion of the
|
||||
animated view stops the frame updater.
|
||||
|
||||
2026-11-24: the completion of a subview with a custom drawRect also set the
|
||||
subview's frame to the target of its animation. When the animated view ended
|
||||
@@ -338,17 +352,9 @@ var _CPAnimationContextStack = nil,
|
||||
collapses animates to no width and keeps its size, the subview kept the frame
|
||||
of no width: People's sidebar scroll view and detail box stayed empty after the
|
||||
item expanded again. When the subview's completion ran after the animated
|
||||
view's, the subview was resized twice.
|
||||
view's, the subview was resized twice. The same completion stopped the frame
|
||||
updater of the animated view, sometimes before that view's own completion.
|
||||
*/
|
||||
if ([aSubview hasCustomDrawRect])
|
||||
{
|
||||
action.completion = function()
|
||||
{
|
||||
if (idx == count - 1)
|
||||
[animatorClass stopUpdaterWithIdentifier:[anAction.root UID]];
|
||||
};
|
||||
}
|
||||
|
||||
var animate = !needsPeriodicFrameUpdates;
|
||||
[self getAnimations:cssAnimations getTimers:timers usingAction:action cssAnimate:animate];
|
||||
}];
|
||||
|
||||
@@ -316,6 +316,25 @@ function _CPViewAnimatorValueFunctionInAppearance(aFunction, aView)
|
||||
CPLog.warn("Could not find FrameUpdater with identifier " + anIdentifier);
|
||||
}
|
||||
|
||||
/*
|
||||
Stops the frame updater of the animation of a view, when it has one, and gives back to each
|
||||
view it updated the frame that view had when the animation started. The views get their
|
||||
frames back in the order they were added, so a view's own frame comes after the frame of
|
||||
its superview, whose change would otherwise resize it again.
|
||||
*/
|
||||
+ (void)_finishFrameUpdaterWithIdentifier:(CPString)anIdentifier
|
||||
{
|
||||
var frameUpdater = FRAME_UPDATERS[anIdentifier];
|
||||
|
||||
if (!frameUpdater)
|
||||
return;
|
||||
|
||||
delete FRAME_UPDATERS[anIdentifier];
|
||||
|
||||
frameUpdater.stop();
|
||||
frameUpdater.restoreInitialFrames();
|
||||
}
|
||||
|
||||
- (BOOL)needsPeriodicFrameUpdatesForKeyPath:(CPString)aKeyPath
|
||||
{
|
||||
return ((aKeyPath == @"frame" || aKeyPath == @"frameSize") &&
|
||||
@@ -458,6 +477,7 @@ var FrameUpdater = function(anIdentifier)
|
||||
this._duration = 0;
|
||||
this._stop = false;
|
||||
this._targets = [];
|
||||
this._initialFrames = [];
|
||||
this._callbacks = [];
|
||||
|
||||
var frameUpdater = this;
|
||||
@@ -517,10 +537,17 @@ FrameUpdater.prototype.addTarget = function(target, keyPath, duration)
|
||||
{
|
||||
this._duration = MAX(this._duration, duration);
|
||||
this._targets.push(target);
|
||||
this._initialFrames.push(CGRectMakeCopy([target frame]));
|
||||
this._callbacks.push(callback);
|
||||
}
|
||||
};
|
||||
|
||||
FrameUpdater.prototype.restoreInitialFrames = function()
|
||||
{
|
||||
for (var i = 0; i < this._targets.length; i++)
|
||||
[this._targets[i] setFrame:this._initialFrames[i]];
|
||||
};
|
||||
|
||||
var createUpdateFrame = function(aView, aKeyPath)
|
||||
{
|
||||
if (aKeyPath !== "frame" && aKeyPath !== "frameSize" && aKeyPath !== "frameOrigin")
|
||||
|
||||
Reference in new issue
Block a user