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

Trigger animation from ViewModel #4

Open
Genfood opened this issue Dec 13, 2022 · 6 comments
Open

Trigger animation from ViewModel #4

Genfood opened this issue Dec 13, 2022 · 6 comments

Comments

@Genfood
Copy link

Genfood commented Dec 13, 2022

Is it possible to start the animation from the ViewModel?

@Strypper
Copy link

@jsuarezruiz ?

@jsuarezruiz
Copy link
Owner

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
Copy link

Can you help us provide a small example?

We still don't understand what you are describing.

@hiroian
Copy link

hiroian commented May 8, 2024

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
Copy link
Contributor

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

KakaoTalk_Recording_20240520_233405.mp4
    <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
Copy link

hiroian commented May 21, 2024

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

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

5 participants