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

Feature request: OnMouseEvents #7

Open
Jerajo opened this issue Nov 14, 2018 · 3 comments
Open

Feature request: OnMouseEvents #7

Jerajo opened this issue Nov 14, 2018 · 3 comments

Comments

@Jerajo
Copy link

Jerajo commented Nov 14, 2018

It would be great if we can make animations on Mouse Events.

Example

<Image 
    Source="Images/MyImage.png" 
    Width="250"
    tz:Transitionz.Opacity="{tz:OpacityParams Duration=200, 
                                              From=0.65, 
                                              To=1, 
                                              TransitionOn=MouseEnter}" />

Event List

  • MouseEnter
  • MouseLeave
  • MouseLeftButtonDown
  • MouseLeftButtonUp
@andyb1979
Copy link
Contributor

Nice feature request! I'm a bit busy right now on commercial projects, but if you or anyone else wanted to contribute, happy to accept and merge a pull request.

Best regards,
Andrew

@andyb1979
Copy link
Contributor

andyb1979 commented Mar 22, 2019

I just realised, and I'm quite thick ... that you can do this already with the library.

Simply set the Transitions.Opacity property manually in a mouse event, e.g.

<TextBlock x:Name="textBlock" 
   Text="Hover over me!" Opacity="0.2" FontSize="36" HorizontalAlignment="Center" VerticalAlignment="Center"
   MouseEnter="OnMouseEnter"
   MouseLeave="OnMouseLeave">
</TextBlock>
private void OnMouseEnter(object sender, MouseEventArgs e)
{
   Transitionz.SetOpacity(textBlock, new OpacityParams() { From = 0.2, To = 1.0, Duration = 300});
}

private void OnMouseLeave(object sender, MouseEventArgs e)
{
   Transitionz.SetOpacity(textBlock, new OpacityParams() { From = 1.0, To = 0.2, Duration = 300 });
}

Sure it's nicer in one line but it is possible. Also possible with Triggers.

@Aurumaker72
Copy link
Contributor

Also possible with Triggers

Yep, here's an idea:

           <Control.Triggers>
               <EventTrigger RoutedEvent="MouseEnter" >
                   <BeginStoryboard Storyboard="{StaticResource ...}"/>
               </EventTrigger>
               <EventTrigger RoutedEvent="MouseLeave" >
                   <BeginStoryboard Storyboard="{StaticResource ...}"/>
               </EventTrigger>
           </Control.Triggers>

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

No branches or pull requests

3 participants