On two finger touch rotate fires automatic before actual rotating fingers
See original GitHub issueWhen touch the screen to hold the element by two fingers, rotate event get fired instantly. Rotate event suppose to be fire only on actual rotating fingers. Important thing is that, When we touch element by two fingers it return different rotation all the time.
bellow is my code, please take a look on it and let me know.
var mc = new Hammer( $( ".rotate" )[ 0 ], {
tap :{enable:false}
} );
// create a pinch and rotate recognizer
// these require 2 pointers
var pinch = new Hammer.Pinch();
var rotate = new Hammer.Rotate();
// we want to detect both the same time
pinch.recognizeWith(rotate);
// add to the Manager
mc.add([pinch, rotate]);
var liveScale = 1;
var currentRotation = 0;
var prevRotation = 0;
var rotation = 0;
var scale=1, last_scale = $('.rotate').width(),
rotation= 1, last_rotation, dragReady=0,
lastgestureRotation = 0;
$scope.rotateInProgress = false;
var lastPosX = 0, lastPosY = 0, posX = 0, posY =0;
mc.on("pinch pinchstart pinchend rotate rotatestart rotateend pan panend tap multitap", function(e) {
e.preventDefault();
switch( e.type ) {
case 'rotatestart':
$scope.rotateInProgress = true;
last_scale = scale;
last_rotation = rotation;
break;
case 'rotateend':
last_scale = scale;
last_rotation = e.rotation;
lastgestureRotation = e.rotation;
break;
case 'rotate':
lastgestureRotation = e.rotation;
rotation = last_rotation + e.rotation;
//scale = Math.max(1, Math.min(last_scale * e.scale, 10));
break;
case 'pinch':
scale = scale = Math.max(1, Math.min(last_scale * e.scale, 10));
break;
case 'pinchstart':
last_scale = scale;
break;
case 'pinchend':
last_scale = scale;
break;
case 'pan':
posX = e.deltaX + lastPosX;
posY = e.deltaY + lastPosY;
break;
case 'panend':
lastPosX = posX;
lastPosY = posY;
break;
case 'tap':
break;
case 'multitap':
break;
}
$scope.setProfilePicLocation( { rotation : rotation, scale : scale } ); //set rotation
$scope.setProfilePicLocation( null, { posX : posX+'px', posY : posY+'px' } ); //set location
Issue Analytics
- State:
- Created 8 years ago
- Comments:10
Top Results From Across the Web
Handling touchscreen or mouse events: Rotate Touch Handler
The Rotate Touch Handler is optimized to detect one finger rotation gestures. When the user touches the screen and drags the finger, the...
Read more >hammerjs - Bountysource
When touch the screen to hold the element by two fingers, rotate event get fired instantly. Rotate event suppose to be fire only...
Read more >Handling long-press gestures | Apple Developer Documentation
Measure the relative rotation of two fingers on the screen, and use that motion to rotate your content.
Read more >Use One Touch to Rotate or Scale with Fingers - YouTube
In this short tutorial, I show you how to use the Fingers - Gesture for Unity asset to use a one finger gesture...
Read more >Implementing Multi-Touch Gestures with Touch Groups and ...
One-finger vs. multi-finger: “one-finger” gestures involve one touch at a time whereas “multi-finger” gestures involve multiple fingers moving in synchrony.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@tanelthm thanks for your valuable time
My issues has been solved. I was trying the code given at hammer.js examples. But actually as per my requirement, I suppose to have addition or subtraction of start and end rotations difference, instead of applying actual rotated angle to the element. So below is my updated code, It worked for me.
I think this has been solved by: https://github.com/hammerjs/hammer.js/pull/982/files
I applied the patch and it worked great