#747 – Implementing Inertia during Touch Manipulation

We’ve talked about how to calculate a value for inertial deceleration.  Once you know what deceleration value that you want, you can implement inertia during touch manipulation by handling the ManipulationInertiaStarting event.

The ManipulationInertiaStarting event will fire after the user lifts their finger off of the screen.  In the event handler, if you specify a deceleration value, the inertia will be modeled and the object will continue to move after the user lifts their finger.

The example below specifies a deceleration value of 40 in/sec^2.  It also dumps out the initial velocity of the object being translated, for informational purposes.

Note that we are setting up inertia for translation only.  We could also specify different deceleration values for rotation and scaling to get touch-based inertia while rotating or scaling.

        private void Image_ManipulationInertiaStarting(object sender, ManipulationInertiaStartingEventArgs e)
        {
            e.TranslationBehavior.DesiredDeceleration = 40.0 * 96.0 / (1000.0 * 1000.0);
            Trace.WriteLine(e.TranslationBehavior.InitialVelocity);
        }

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

3 Responses to #747 – Implementing Inertia during Touch Manipulation

  1. Pingback: Dew Drop – February 1, 2013 (#1,492) | Alvin Ashcraft's Morning Dew

  2. Pingback: #754 – Implementing Inertia for Expansion during Touch Manipulation « 2,000 Things You Should Know About WPF

  3. Pingback: #755 – Implementing Rotational Inertia during Touch Manipulation « 2,000 Things You Should Know About WPF

Leave a comment