How to programmatically navigate in a FlipView with swipe animations - windows-store-apps

The Windows Dev Center states regarding the UseTouchAnimationsForAllNavigation property:
The XAML FlipView control supports three modes of navigation; touch-based, button-based and programmatic. When a user navigates by touch, the FlipView items scroll smoothly into view. When you set this property to true, the same navigation animation occurs whether the navigation is touch-based, button-based and programmatic.
I'm currently navigating from my page's code behind by assigning the SelectedItem property of the FlipView:
FlipView.SelectedItem = FlipView.Items.Last();
However, the swipe animation does not show. How can I enable it?

Meanwhile, I was able to solve this problem. I have a button that triggers the navigation to the next FlipViewItem. This button however was placed in a FlipViewItem.
With my setup (touch device), nothing happend. Then I tried clicking the button with the mouse and it worked. After I disabled UseTouchAnimationsForAllNavigation, it also worked using touch input. In my tests, I placed the button outside of the FlipView and it did work using animations.
Here's the problem: When tapping the button, the navigation animation tries to start (SelectedIndex is set correctly), but stopped because the user blocks the animation by still touching the button. So, the navigation is cancelled and SelectionChanged reports the current page.
The solution is to set ManipulationMode of the Button to All. After that, you can't flip the FlipViewItem when touching the button, but the animation executes and it works like charm.

I solved the same problem in a different way. As Chliebel said, it is because your finger is still touching the control, so flipview cannot animate. So I gave a small break after before navigating. By the time user would have released the finger and it works !!!
await Task.Delay(100);
flipView.SelectedIndex += 1;

For me, ChristiaanV's answer has helped:
Animation only occurs when you navigate to the previous or next item
in the FlipView.
So I've set up a while loop to set the selected index to the previous / next one until I reach the desired page.
Example Code:
If you'd like to reach the first page:
while(flipView.SelectedIndex > 0)
{
flipView.SetValue(FlipView.SelectedIndexProperty, flipView.SelectedIndex - 1);
}

Here's a compact solution I found, similar to Bhawk1990's:
//nb is the index you wish to get to.
if (nb > flipview.SelectedIndex)
while (flipview.SelectedIndex != nb)
flipview.SelectedIndex++;
else if (nb < flipview.SelectedIndex)
while (flipview.SelectedIndex != nb)
flipview.SelectedIndex--;

I spent a couple of days figuring out why touch animation does not work when I programmatically change FlipView selected item when UseTouchAnimationsForAllNavigation="True".
I found a setting which controls animation machine wide. Somehow this setting was disabled:
Settings->Visual options->Play animations in Windows

Related

how to stop webpage click events from like firefox/chrome developer console inspector tools?

Question #1:
I am working on a chrome extension where it requires an inspector like tool to let user hover on a webpage. And to show outline on hover on a DOM element.
When user clicks on any element, I need to show a popup besides the element.
But at the same time that elements click event must not execute. It is very similar to developer consoles inspector tool. Can you please help how to do this ?
Question #2:
Can you please suggest why Chrome developer console's inspector tool does not work in this case ?
To reproduce:
1. Go to https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjQ377A-8vQAhUHQY8KHUHxCv0QFggaMAA&url=https%3A%2F%2Fconsole.developers.google.com%2F&usg=AFQjCNF0eH059mv86nMIlRmfsf42kde-wA&bvm=bv.139782543,d.c2I
2. Click on "products & services" menu (3 horizontal lines icon) in left top. A slide menu will open.
3. Start developer console (click F12).
4. Select anything on this menu.
Actual result: Side menu closes.
Expected result: Side menu should not have closed and developer console should have shown its html.
I got a solution to this. I created a div (of size 4x4 px). I move
this div with the mouse move event. I set the div coordinates so
that mouse tip is exactly at the middle of the div.
Div background is kept transparent, so that it is not visible to
users. So when user clicks on element, he is actually clicking on
the div.
And inside the div mouse down event, I stop event propagation.
Please let me know if anyone reading need any more pointers.
You may have tried this already, but I'd suggest adding a click listener to any clickable items, by adding these lines:
$(document).click(function() {
event.stopPropagation();
event.preventDefault();
});
Though because of the way things bubble up in the DOM, events attached to children may still fire, depending on the browser.

Windows Store: textbox inside flipview, cannot dismiss SIP keyboard when lost focus

I am using a full-screen flipview to allow a background to rotate behind a set of inputs. if you tap the input textbox, the SIP keyboard appears.
however, tapping outside of the textbox does not dismiss the keyboard as expected. I finally realized it is because of the flipview. I verified this by adding a 250 margin around the flipview. if i tap in the area covered by the control it still doesn't dismiss, but if I tap the areas covered by the margins (that is, outside the flipview) the SIP does dismiss as expected.
I tried setting IsTabStop to false and IsTapEnabled to false for the flipview, but the SIP still remains active unless i tap outside the flipview.
since we need the flipview to be full screen, I need to know if there is a way to disable the control so that it closes the keyboard.
can this be done? which property or event on the flipview can I leverage to make this happen?
aha, by handling the "tapped" event I did the old trick of disabling and enabling the flipview and sure enough the keyboard dismissed!

flyout should not hide when the user taps/clicks in metro app

In my metro style app (windows 8) I have created an page overlay and a flyout displaying an message. When the user clicks on the page the flyout message goes to hidden. But I want flyout to remain even when the user clicks on the overlay page. I am using HTML5 and WinJS.
Is there anyway I can achieve the above scenario using someother control or can I prevent the page to stop reacting to events when the user taps/clicks on the screen.
This is not really supported -- the Flyout itself doesn't have the concept of being persistent/sticky/modal. If you look at the code in base.js, you'll see that it doesn't expose any code to leverage the inbuilt sticky behavior that is used in the appbar (which is kinda of flyout, it turns out.
There are a couple things you can do:
Pass "_sticky: true" to the constructor of the flyout. e.g <div data-win-control="WinJS.UI.Flyout" data-win-options="{ _sticky: true}">
Attach a click handler to the top of the document, and if it's on the click eating div that the flyout creates, cancel the event
Create your own UI by simply adding a new div to the body, and absolute positioning it.

Flash buttons flicker continuously when compiled

I am looking for some help with Flash (CS5 version). I have a situation where if try to put a button on the stage with visible differences in the up/over/down/hit states, when I compile the document into a .swf, the button will continuously flicker through each state in order very quickly. Also, if I break the AS3 code in the Main class file, hidden parts of a slider bar component will flicker between visible and not. I'm talking Japanese-style, seizure-inducing flicker here. I've searched my code for recursive function calls and tried deleting and re-adding components and buttons, but to no avail. Any ideas on what could be up?
Well, it seems to me you aren't using stop() to stop the button at the frame you want.
If it isn't this, then there is some error with your ActionScript, which will show up in the output panel, so check that.
When you say 'button' is it an instance of the Button Class and have you set the instance type to Button?
i.e.
Select the button in your library panel, right click and choose 'Properties'. Then set the Type to Button.
Next, select the instance of the button on the stage, open the Properties panel and just underneath where you type the instance name you should see a drop down menu containing MovieClip, Button and Graphic. Set it to Button.

Page flip effect on button press in html5

I'm looking at this:
http://www.netmagazine.com/tutorials/create-page-flip-effect-html5-canvas
However, I have one problem with that - I need to be able to click on the pages, even the edges, without triggering the page turn. I want the pages to turn when a button outside of the canvas is pressed. Is this possible using the base they provided, or do I need to go an entirely different direction?
Yes that can be done.
From what i can see, you need a click event that doesnt trigger the page drag. You need to assign a flag for this.
Let Drag = mouse drag/mouse move, down = mouse down, release = mouse release events respectively.
Initialize your flag variable as false. When a drag event is encountered it becomes true. Otherwise it remains false. As long as it is false when the mouse release event occurs it can be treated as a click. Thats the basic principle behind using mousedown and mouseup as a click event.
You will have to use e.srcElement or e.target to give you the element your cursor is currently positioned over inorder to trigger click functions relative to that element.
If you want a more detailed explanation on the page flip technique then check this out. Helped me lot.