Aurelia animations based on events - javascript

How do you animate elements in Aurelia based on events? (i.e., touch events in the browser called touchstart, touchmove, touchend)
Let's take the Android Gmail app as an example for this question. You can archive certain messages by swiping a message to the right or left and you can extend the side menu by pressing the hamburger icon in the top left or start swiping on the left edge of the screen. These elements move depending how much you've moved your finger from the begin position. How would you do this in Aurelia?

Related

Can I prevent viewport manipulation though the right mouse button in X3DOM?

I am using the right mouse button for custom user interaction - even when in "view" mode - with x3d.runtime.turnTable() enabled.
Can I prevent x3d from reacting to the right mouse button completely?
Zooming is still ok using the mouse wheel, and the left mouse button to rotate - so there's nothing really missing.

Move/Slide Page To Left/Right Whe User Slide Left/Rigt With Finger On Touch Device

I wanted my webpage can change when user slide left/right using their finger on touch device (android/tablet). I found following source code that works what i need:
http://padilicious.com/code/touchevents/
But that has few limitations. It doesn't move/slide the page/element to left/right. It just change the page (href/page location). So, user don't understand whether they slide it correctly or not.
but on touch screen device like gallery you can see when user slide to left/right image move to left/right as user move the finger and it goes away left/right when user finish the slide.
i want to do something like that.
so, when user move finger my page will move with the finger too and when he remove the finger my page will go left/right with slide transition effect.
here is the sample code for page transition...
http://www.w3schools.com/jquerymobile/tryit.asp?filename=tryjqmob_trans_slide
hope that make sense..
You can use jQt to capture touch screen swipe events. After capturing these events you can easily make an application that navigates like you want. Also jQt has it's own webkit animations. And they are pretty cool.
You can also check this Safari Web Content Guide to capture these events yourself.
Another nice tutorial for detecting swipes for touch screens.

How to contain my mouse pointer within a canvas/div?

I am currently trying to make a small html5 canvas game.
I want my mouse pointer to stay within a div element or canvas boundary.
Point me in the right direction please.
You can use the new Pointer Lock API. It is now supported by Chrome, Firefox, Edge, Opera, and Safari.
Excerpt from the article linked above (my emphasis):
The Pointer Lock API (formerly called Mouse Lock API) provides input methods based on the movement of the mouse over time (i.e., deltas), not just the absolute position of the mouse cursor in the viewport. It gives you access to raw mouse movement, locks the target of mouse events to a single element, eliminates limits on how far mouse movement can go in a single direction, and removes the cursor from view. It is ideal for first person 3D games, for example.
More than that, the API is useful for any applications that require significant mouse input to control movements, rotate objects, and change entries, for example allowing users to control the viewing angle by moving the mouse around without any button clicking. The buttons are then freed up for other actions. Other examples include apps for viewing maps or satellite imagery.
Pointer lock lets you access mouse events even when the cursor goes past the boundary of the browser or screen. For example, your users can continue to rotate or manipulate a 3D model by moving the mouse without end. Without Pointer lock, the rotation or manipulation stops the moment the pointer reaches the edge of the browser or screen. Game players can now click buttons and swipe the mouse cursor back and forth without worrying about leaving the game play area and accidentally clicking another application that would take mouse focus away from the game.
Also see the link for examples.

How can I mimic alt-tabbing between windows using divs in a web page?

I'm looking for a plugin or a way to mimic alt-tabbing between windows using divs in a web page. To clarify, the user will not be pressing alt-tab, but will alternate between the divs with the mouse.
To be precise:
I need to popup a set of divs
That the user can navigate left or right, similar to alt-tabbing between windows.
The center div should be large and the side divs should be increasingly smaller.
When the user moves the mouse cursor left, it should rotate the list right, moving the center div to the left.
I also want it to work with swipe events on a touch device (but I can implement that separately).
These should work:
jcoverflip
Content Flow
Let me know if they aren't what you're looking for (and why).

jQuery & Touch/Mobile: Perform Function on Swipe Left / Right

How can I achieve to let jQuery/JavaScript perform a jQuery-Function if a mobile-user swipes with one finger to the left an another function if he swipes to the right?
I like to animate scrollLeft and scrollRight to a certain position if the user swipes left/right. I'm doing the same for desktop with keyboard-navigation trough Arrow Left/Right which works perfectly. Now I need the same for swiping on touch devices.
(if possible without jQuery Mobile or another additional library)
ok heres a long answer but it worth it:
jQuery (Swipe vs. Touch) pageX and pageY keep returning 0
Hope it helps
Using some of the following events you can work out which direction a swipe has been made
touchstart: Occurs when a finger is placed on the screen
touchend: Occurs when a finger is removed from the screen
touchmove: Occurs when a finger already placed on the screen is moved across the screen
touchcancel: Occurs when a touch is cancelled before the finger is actually removed from the screen
Record the x,y position on touchstart and again on touchend and determine which direction a swipe has been made

Categories