Skip to content
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

Fixes #1150. #1153

Merged
merged 4 commits into from
Jun 9, 2017
Merged

Fixes #1150. #1153

merged 4 commits into from
Jun 9, 2017

Conversation

pekspro
Copy link
Contributor

@pekspro pekspro commented May 8, 2017

No description provided.

Copy link
Contributor

@nmetulev nmetulev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nmetulev nmetulev added this to the v1.5 milestone May 15, 2017

_contentStoryboard.Completed += (s, a) =>
{
_commandContainer.Opacity = 0.0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this get set back to 1?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question! In ContentGrid_ManipulationStarted the opacity is also set to 0 when the sliding starts. Then when the control has been moved the opacity is set to 1 in ContentGrid_ManipulationDelta. This PR just sets the opacity to 0 when the slide has been completed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -254,6 +254,11 @@ private void ContentGrid_ManipulationStarted(object sender, ManipulationStartedR

_contentStoryboard = new Storyboard();
_contentStoryboard.Children.Add(_contentAnimation);

_contentStoryboard.Completed += (s, a) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see the event unsubscribed when the control is unloaded. Can then be resubscribed when loaded if the storyboard is not null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this has been fixed.

@@ -522,6 +529,18 @@ private void ContentGrid_ManipulationDelta(object sender, ManipulationDeltaRoute
SwipeStatus = newSwipeStatus;
}

private void ContentStoryboard_Completed(object sender, object e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The storyboard is created once, but it used every time the manipulation happens. However, the storyboard completed event is unsubscribed when it completes the first time. This means if I flick to the side twice, it will not set the opacity back to 0 the second time. Best to unsubscribe when the control is unloaded.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that’s fixed. But what are the benefits of doing this? Shouldn’t other events also be unsubscribed when the control is unloaded?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skendrot ping

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's always best practice but that's outside the scope of this PR 😄

@@ -522,6 +529,18 @@ private void ContentGrid_ManipulationDelta(object sender, ManipulationDeltaRoute
SwipeStatus = newSwipeStatus;
}

private void ContentStoryboard_Completed(object sender, object e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It's always best practice but that's outside the scope of this PR 😄

@@ -256,6 +268,12 @@ private void ContentGrid_ManipulationStarted(object sender, ManipulationStartedR
_contentStoryboard.Children.Add(_contentAnimation);
}

if (!_contentStoryboardCompletedIsSubscribed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of keeping a variable if the event has been subscribed, subscribe to it when creating the storyboard and then in the loaded event check if the storyboard is not null and subscribe

        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            if (_contentStoryboard != null)
            {
                _contentStoryboard.Completed += ContentStoryboard_Completed;
            }
        }

        private void OnUnloaded(object sender, RoutedEventArgs e)
        {
            if (_contentStoryboard != null)
            {
                _contentStoryboard.Completed -= ContentStoryboard_Completed;
            }
        }

@nmetulev nmetulev merged commit e9a4df0 into CommunityToolkit:dev Jun 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants