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,21 +2544,24 @@ function onCanvasDrag( event ) {
} }
function onCanvasDragEnd( event ) { function onCanvasDragEnd( event ) {
var gestureSettings;
if (!event.preventDefaultAction && this.viewport) { if (!event.preventDefaultAction && this.viewport) {
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType ); var gestureSettings = this.gestureSettingsByDeviceType(event.pointerType);
if ( gestureSettings.flickEnabled && event.speed >= gestureSettings.flickMinSpeed ) { if (gestureSettings.flickEnabled &&
var amplitudeX = gestureSettings.flickMomentum * ( event.speed * Math.cos( event.direction - (Math.PI / 180 * this.viewport.degrees) ) ), event.speed >= gestureSettings.flickMinSpeed) {
amplitudeY = gestureSettings.flickMomentum * ( event.speed * Math.sin( event.direction - (Math.PI / 180 * this.viewport.degrees) ) ), var amplitudeX = 0;
center = this.viewport.pixelFromPoint( this.viewport.getCenter( true ) ), if (this.panHorizontal) {
target = this.viewport.pointFromPixel( new $.Point( center.x - amplitudeX, center.y - amplitudeY ) ); amplitudeX = gestureSettings.flickMomentum * event.speed *
if( !this.panHorizontal ) { Math.cos(event.direction);
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);
} }
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.panTo(target, false);
} }
this.viewport.applyConstraints(); this.viewport.applyConstraints();