[Windows 8] How to add “tilt effect” to your controls ?
September 18th, 2012 | Posted by in .NET | Article | HTML5 | Windows 8 | WinJS | WinRT | Read: 926The “tilt effect” was introduced in Windows Phone and give to developers the possibility to provide visual feedback to users by performing a small scale when the pointer is down on the control (and restoring the control to its original scale’s value when the pointer is up).
Here is a quick (but useful !) tip if you want to add this “tilt effect” to your controls:
(function () { "use strict"; function addTiltEffect(control) { control.addEventListener('MSPointerDown', function () { WinJS.UI.Animation.pointerDown(control); }, false); control.addEventListener('MSPointerUp', function () { WinJS.UI.Animation.pointerUp(control); }, false); control.addEventListener('MSPointerOut', function () { WinJS.UI.Animation.pointerUp(control); }, false); } WinJS.Namespace.define("UiHelpers", { AddTiltEffect: addTiltEffect }); })();
As you can see, we just add handlers to the PointerDown, PointerUp and PointerOut events and we call the function pointerDown and pointerUp provided by the WinJS Framework !
Have fun and happy coding!
You can follow any responses to this entry through the RSS 2.0 You can leave a response, or trackback.





Pingback: [Windows 8] How to add “tilt effect” to your controls?