AlohaKit.Animations icon indicating copy to clipboard operation
AlohaKit.Animations copied to clipboard

Trigger animation from ViewModel

Open Genfood opened this issue 2 years ago • 6 comments
trafficstars

Is it possible to start the animation from the ViewModel?

Genfood avatar Dec 13 '22 18:12 Genfood

@jsuarezruiz ?

Strypper avatar Dec 21 '23 09:12 Strypper

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. ​

jsuarezruiz avatar Dec 28 '23 10:12 jsuarezruiz

Can you help us provide a small example?

We still don't understand what you are describing.

Strypper avatar Dec 28 '23 12:12 Strypper

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.

hiroian avatar May 08 '24 06:05 hiroian

@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>

lukewire129 avatar May 20 '24 14:05 lukewire129

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

hiroian avatar May 21 '24 07:05 hiroian