-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #4214 - Update AttachedDropShadow visual on layout/visibility #4230
Fix #4214 - Update AttachedDropShadow visual on layout/visibility #4230
Conversation
Thanks michael-hawker for opening a Pull Request! The reviewers will test the PR and highlight if there is any conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌 |
…ment layout changes and visibility changes
9e2353a
to
fb5b405
Compare
@michael-hawker Update fixes all the scenarios I tested in my sample project. Thanks, Michael! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates fixes tested scenarios in my sample project. Thanks!
private static void BindSizeAndScale(CompositionObject source, UIElement target) | ||
{ | ||
var visual = ElementCompositionPreview.GetElementVisual(target); | ||
var bindSizeAnimation = source.Compositor.CreateExpressionAnimation($"{nameof(visual)}.Size * {nameof(visual)}.Scale.XY"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please tell me there was a document describing how to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of? https://docs.microsoft.com/uwp/api/Windows.UI.Composition.ExpressionAnimation
I just asked @Sergio0694 😋. We have helpers in the Toolkit for this, but they're in the Animations package and we don't want to include references to that everywhere.
I also just copied this from the Media package from another internal method and tweaked it... But yeah it is a bit of black magic.
@@ -166,6 +167,16 @@ protected internal override void OnElementContextUninitialized(AttachedShadowEle | |||
_container.Children.Remove(context.SpriteVisual); | |||
} | |||
|
|||
context.SpriteVisual?.StopAnimation("Size"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Sergio0694 any other clean-up I need to do beyond this to clean-up the composition animation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think so, the actual objects would just be disposed normally, we're not doing any specific cleanup in other places of the animation package either, it's mostly just fire and forget as usual. Stopping these animations is the only important bit because otherwise the composition layer will just keep them always active even if the XAML object is gone, but other than that we should be good 😄
Fixes #4214
We weren't updating the shadow visual if the parent element's visibility changed or layout was effected by other elements.
PR Type
What is the current behavior?
In some scenarios the shadow wouldn't be updated by the changes to the parent element.
What is the new behavior?
Shadow is now updated in more scenarios (though maybe not all). We should properly handle
Visibility
,Scale
, and some changes due to Layout updates.Note: I tried with
Canvas
from the implicit animation sample and it seems Canvas moving an object doesn't callLayoutUpdated
on that element... wonder if that's a framework bug (this was the closest open one I could find)? Otherwise, not sure how we detect that in the element...PR Checklist
Please check if your PR fulfills the following requirements:
Other information
@zateutsch you hadn't attached your sample project. Did you want to see if the Preview Package spit out by the CI works in your test project?