Merge pull request #884 from avandecreme/master

Fix flick gesture with rotation. Fix #869
This commit is contained in:
Ian Gilman 2016-03-22 09:18:18 -07:00
commit 55cf2bd6b9

View File

@ -2544,22 +2544,25 @@ function onCanvasDrag( event ) {
} }
function onCanvasDragEnd( event ) { function onCanvasDragEnd( event ) {
var gestureSettings; if (!event.preventDefaultAction && this.viewport) {
var gestureSettings = this.gestureSettingsByDeviceType(event.pointerType);
if ( !event.preventDefaultAction && this.viewport ) { if (gestureSettings.flickEnabled &&
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); event.speed >= gestureSettings.flickMinSpeed) {
if ( gestureSettings.flickEnabled && event.speed >= gestureSettings.flickMinSpeed ) { var amplitudeX = 0;
var amplitudeX = gestureSettings.flickMomentum * ( event.speed * Math.cos( event.direction - (Math.PI / 180 * this.viewport.degrees) ) ), if (this.panHorizontal) {
amplitudeY = gestureSettings.flickMomentum * ( event.speed * Math.sin( event.direction - (Math.PI / 180 * this.viewport.degrees) ) ), amplitudeX = gestureSettings.flickMomentum * event.speed *
center = this.viewport.pixelFromPoint( this.viewport.getCenter( true ) ), Math.cos(event.direction);
target = this.viewport.pointFromPixel( new $.Point( center.x - amplitudeX, center.y - amplitudeY ) );
if( !this.panHorizontal ) {
target.x = center.x;
} }
if( !this.panVertical ) { var amplitudeY = 0;
target.y = center.y; if (this.panVertical) {
amplitudeY = gestureSettings.flickMomentum * event.speed *
Math.sin(event.direction);
} }
this.viewport.panTo( target, false ); var center = this.viewport.pixelFromPoint(
this.viewport.getCenter(true));
var target = this.viewport.pointFromPixel(
new $.Point(center.x - amplitudeX, center.y - amplitudeY));
this.viewport.panTo(target, false);
} }
this.viewport.applyConstraints(); this.viewport.applyConstraints();
} }
@ -2578,7 +2581,7 @@ function onCanvasDragEnd( event ) {
* @property {Object} originalEvent - The original DOM event. * @property {Object} originalEvent - The original DOM event.
* @property {?Object} userData - Arbitrary subscriber-defined object. * @property {?Object} userData - Arbitrary subscriber-defined object.
*/ */
this.raiseEvent( 'canvas-drag-end', { this.raiseEvent('canvas-drag-end', {
tracker: event.eventSource, tracker: event.eventSource,
position: event.position, position: event.position,
speed: event.speed, speed: event.speed,