Fix drag with panHorizontal/panVertical set to false.

This commit is contained in:
Antoine Vandecreme 2016-03-20 11:01:26 -04:00
parent 43a9c14d3b
commit 2386900e29

View File

@ -2542,26 +2542,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 && if (gestureSettings.flickEnabled &&
event.speed >= gestureSettings.flickMinSpeed) { event.speed >= gestureSettings.flickMinSpeed) {
var amplitudeX = gestureSettings.flickMomentum * event.speed * var amplitudeX = 0;
if (this.panHorizontal) {
amplitudeX = gestureSettings.flickMomentum * event.speed *
Math.cos(event.direction); Math.cos(event.direction);
var amplitudeY = gestureSettings.flickMomentum * event.speed * }
var amplitudeY = 0;
if (this.panVertical) {
amplitudeY = gestureSettings.flickMomentum * event.speed *
Math.sin(event.direction); Math.sin(event.direction);
}
var center = this.viewport.pixelFromPoint( var center = this.viewport.pixelFromPoint(
this.viewport.getCenter(true)); this.viewport.getCenter(true));
var target = this.viewport.pointFromPixel( var target = this.viewport.pointFromPixel(
new $.Point(center.x - amplitudeX, center.y - amplitudeY)); new $.Point(center.x - amplitudeX, center.y - amplitudeY));
if( !this.panHorizontal ) {
target.x = center.x;
}
if( !this.panVertical ) {
target.y = center.y;
}
this.viewport.panTo(target, false); this.viewport.panTo(target, false);
} }
this.viewport.applyConstraints(); this.viewport.applyConstraints();