mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-26 07:06:10 +03:00
Fix drag with panHorizontal/panVertical set to false.
This commit is contained in:
parent
43a9c14d3b
commit
2386900e29
@ -2542,27 +2542,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 ) {
|
|
||||||
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 ) {
|
this.viewport.panTo(target, false);
|
||||||
target.x = center.x;
|
|
||||||
}
|
|
||||||
if( !this.panVertical ) {
|
|
||||||
target.y = center.y;
|
|
||||||
}
|
|
||||||
this.viewport.panTo( target, false );
|
|
||||||
}
|
}
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
@ -2581,7 +2579,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,
|
||||||
|
Loading…
Reference in New Issue
Block a user