jsuarezruiz / AlohaKit.Animations

AlohaKit.Animations is a library designed for .NET MAUI that aims to facilitate the use of animations to developers.
MIT License
252 stars 26 forks source link

Trigger animation from ViewModel #4

Open Genfood opened 1 year ago

Genfood commented 1 year ago

Is it possible to start the animation from the ViewModel?

Strypper commented 8 months ago

@jsuarezruiz ?

jsuarezruiz commented 8 months ago

You can create a trigger with a Command BindableProperty, bind the command and init the animation. Similar to https://github.com/jsuarezruiz/AlohaKit.Animations/blob/main/src/AlohaKit.Animations/Triggers/BeginAnimation.cs, but with one command. We can add it to the library. ​

Strypper commented 8 months ago

Can you help us provide a small example?

We still don't understand what you are describing.

hiroian commented 4 months ago

Cab you help us with an example, im also looking for a way to start an animation at the opening of a page without a trigger or a scroll.

lukewire129 commented 3 months ago

@hiroian Take a look at the example below and give it a try!

https://github.com/jsuarezruiz/AlohaKit.Animations/assets/54387261/7c057dc2-ed8e-422f-91a9-305c8771d5c9

    <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:alohakit="clr-namespace:AlohaKit.Animations;assembly=AlohaKit.Animations"
             x:Class="PageLoadAnimation.MainPage">
    <ContentPage.Resources>
        <alohakit:ScaleToAnimation
            x:Key="ScaleToAnimation"
            Target="{x:Reference ImageBot}"
            Duration="10000"
            Scale="2.0"/>
    </ContentPage.Resources>
    <ContentPage.Triggers>
        <EventTrigger Event="Loaded">
            <alohakit:BeginAnimation
                Animation="{StaticResource ScaleToAnimation}" />
        </EventTrigger>
    </ContentPage.Triggers>
    <ScrollView>
        <VerticalStackLayout
            Padding="30,0"
            Spacing="25">
            <Image
                x:Name="ImageBot"
                Source="dotnet_bot.png"
                HeightRequest="185"
                Aspect="AspectFit"
                SemanticProperties.Description="dot net bot in a race car number eight" />

            <Label
                Text="Hello, World!"
                Style="{StaticResource Headline}"
                SemanticProperties.HeadingLevel="Level1" />

            <Label
                Text="Welcome to &#10;.NET Multi-platform App UI"
                Style="{StaticResource SubHeadline}"
                SemanticProperties.HeadingLevel="Level2"
                SemanticProperties.Description="Welcome to dot net Multi platform App U I" />

            <Button
                x:Name="CounterBtn"
                Text="Click me" 
                SemanticProperties.Hint="Counts the number of times you click"
                Clicked="OnCounterClicked"
                HorizontalOptions="Fill"/>
        </VerticalStackLayout>
    </ScrollView>
</ContentPage>
hiroian commented 3 months ago

Thanks @lukewire129 ! Exactly what i was looking for! Already implementing it in my project! 😃