# Persistent animation on button tapped handler

**URL:** https://forums.fusetools.com/t/persistent-animation-on-button-tapped-handler/2963
**Category:** How-to Discussions
**Created:** [May 7, 2015, 9:39am UTC](https://forums.fusetools.com/t/persistent-animation-on-button-tapped-handler/2963 "2015-05-07T09:39:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![holly.mary.bagley](https://avatars.discourse-cdn.com/v4/letter/h/258eb7/32.png) [@holly.mary.bagley](https://forums.fusetools.com/u/holly.mary.bagley)
#### Post date: [May 7, 2015, 9:39am UTC](https://forums.fusetools.com/t/persistent-animation-on-button-tapped-handler/2963/1 "2015-05-07T09:39:44Z")

</div>

I’ve created a nav menu that animates a rectangle to slide to the position of the pressed button (so the user can see the transition to a new page). I’m using Tapped and Focusing. All works fine, and the rectangle stays where it is until I click on another button, but - the rectangle reverts back to its starting position when I start to scroll on other page elements outside of the nav bar.

Is there any way to set this in pure ux so that the rectangle will only move if a nav button is pressed? Some way to say ignore clicks on the page outside the navbar?

Here is my code:

```auto
<NavigationBar DockPanel.Dock="Top">
                <GridLayout RowCount="1" ColumnCount="3" />
                <Rectangle ux:Binding="Appearance" ux:Name="Rectangle1" WidthUnit="Percent" Width="33.3" HeightUnit="Percent" Height="100" Alignment="BottomLeft" Margin="1,0,0,0" Padding="0">
                        <SolidColor Color="0,0,0,0.2" ux:Name="bgColor" />
                </Rectangle>

                <NavButton Text="test">
                    <Pressing>
                        <NavigateTo Context="_nav" Target="_page1" />
                    </Pressing>
                    <!-- modify the bg rectangle -->
                    <Tapped>
                        <GiveFocus />
                    </Tapped>
                    <Focusing>
                        <Move Target="Rectangle1" X="0" RelativeTo="Size" Easing="SinusoidalInOut" Duration="0.3" />
                    </Focusing> </NavButton>

                <NavButton Text="Page 2">
                    <Pressing>
                        <NavigateTo Context="_nav" Target="_page2" />
                    </Pressing>
                    <Tapped>
                        <GiveFocus />
                    </Tapped>
                    <Focusing>
                        <Move Target="Rectangle1" X="1" RelativeTo="Size" Easing="SinusoidalInOut" Duration="0.3" />
                    </Focusing> </NavButton>

                <NavButton Text="Page 3">
                    <Pressing>
                        <NavigateTo Context="_nav" Target="_page3" />
                    </Pressing>
                    <Tapped>
                        <GiveFocus />
                    </Tapped>
                    <Focusing>
                        <Move Target="Rectangle1" X="2" RelativeTo="Size" Easing="SinusoidalInOut" Duration="0.3" />
                    </Focusing> </NavButton>

            </NavigationBar>
            --pages and main content follows--

```

Navbutton styles are in a separate file:

```auto
<!-- Reset navbutton styles -->
    <NavButton ux:Cascade="false" /> 

<!-- Initiate navbutton class -->
    <Button ux:Class="NavButton" Margin="2, 0, 0, 0" Padding="0">
        <Rectangle ux:Binding="Appearance">
            <SolidColor Color="1,1,1,0.1" ux:Name="NavBG" />
        </Rectangle>
        <Tapped>
            <GiveFocus />
        </Tapped>
        <Focusing>
        </Focusing> </Button>

```

---

<div class="post-metadata">

### Author: ![Eivind](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/eivind/32/575_2.png) [@Eivind](https://forums.fusetools.com/u/Eivind)
#### Post date: [May 8, 2015, 9:56am UTC](https://forums.fusetools.com/t/persistent-animation-on-button-tapped-handler/2963/2 "2015-05-08T09:56:05Z")

</div>

I’ve been trying to do the same, and also havent figured out how

---

<div class="post-metadata">

### Author: ![Anders\_Lassen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_lassen/32/522_2.png) [@Anders\_Lassen](https://forums.fusetools.com/u/Anders_Lassen)
#### Post date: [May 8, 2015, 10:05am UTC](https://forums.fusetools.com/t/persistent-animation-on-button-tapped-handler/2963/3 "2015-05-08T10:05:24Z")

</div>

Hi guys,

In yesterday’s release, we included `<StateGroup>` and `<State>` which makes cases like this easier.

Basically, you define a `<State>` for each of the states an object can be in.

Here is an example use case:

[https://gist.github.com/Duckers/edafa6caf7cbf338b195](https://gist.github.com/Duckers/edafa6caf7cbf338b195)

---

<div class="post-metadata">

### Author: ![Anders\_Lassen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_lassen/32/522_2.png) [@Anders\_Lassen](https://forums.fusetools.com/u/Anders_Lassen)
#### Post date: [May 8, 2015, 10:12am UTC](https://forums.fusetools.com/t/persistent-animation-on-button-tapped-handler/2963/4 "2015-05-08T10:12:19Z")

</div>

And here is a an bit more fancy example using animation mixers: [https://gist.github.com/Duckers/8c93e3fb28dbaf4df6cd](https://gist.github.com/Duckers/8c93e3fb28dbaf4df6cd)

And a video of how it looks:

We will clean these up and publish as official examples soon 🙂

---

<div class="post-metadata">

### Author: ![holly.mary.bagley](https://avatars.discourse-cdn.com/v4/letter/h/258eb7/32.png) [@holly.mary.bagley](https://forums.fusetools.com/u/holly.mary.bagley)
#### Post date: [May 11, 2015, 9:54am UTC](https://forums.fusetools.com/t/persistent-animation-on-button-tapped-handler/2963/5 "2015-05-11T09:54:24Z")

</div>

Fantastic - this works perfectly!
