mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 22:56:11 +03:00
Improved Viewer Options Support in Gesture Handling
Apply constrainDuringPan option in flick and drag gesture handling. Apply panHorizontal and panVertical options in flick and pinch gesture handling.
This commit is contained in:
parent
378bfb9532
commit
bd11af6571
@ -2319,7 +2319,7 @@ function onCanvasDrag( event ) {
|
|||||||
event.delta.y = 0;
|
event.delta.y = 0;
|
||||||
}
|
}
|
||||||
this.viewport.panBy( this.viewport.deltaPointsFromPixels( event.delta.negate() ), gestureSettings.flickEnabled );
|
this.viewport.panBy( this.viewport.deltaPointsFromPixels( event.delta.negate() ), gestureSettings.flickEnabled );
|
||||||
if( this.constrainDuringPan && !gestureSettings.flickEnabled ){
|
if( this.constrainDuringPan ){
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2355,11 +2355,17 @@ function onCanvasDragEnd( event ) {
|
|||||||
|
|
||||||
if ( !event.preventDefaultAction && this.viewport ) {
|
if ( !event.preventDefaultAction && this.viewport ) {
|
||||||
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
||||||
if ( gestureSettings.flickEnabled && event.speed >= gestureSettings.flickMinSpeed && !event.preventDefaultAction && this.viewport ) {
|
if ( gestureSettings.flickEnabled && event.speed >= gestureSettings.flickMinSpeed ) {
|
||||||
var amplitudeX = gestureSettings.flickMomentum * ( event.speed * Math.cos( event.direction ) ),
|
var amplitudeX = gestureSettings.flickMomentum * ( event.speed * Math.cos( event.direction ) ),
|
||||||
amplitudeY = gestureSettings.flickMomentum * ( event.speed * Math.sin( event.direction ) ),
|
amplitudeY = gestureSettings.flickMomentum * ( event.speed * Math.sin( event.direction ) ),
|
||||||
center = this.viewport.pixelFromPoint( this.viewport.getCenter( true ) ),
|
center = this.viewport.pixelFromPoint( this.viewport.getCenter( true ) ),
|
||||||
target = this.viewport.pointFromPixel( new $.Point( center.x - amplitudeX, center.y - amplitudeY ) );
|
target = this.viewport.pointFromPixel( 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();
|
||||||
}
|
}
|
||||||
@ -2423,15 +2429,25 @@ function onCanvasRelease( event ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasPinch( event ) {
|
function onCanvasPinch( event ) {
|
||||||
var gestureSettings;
|
var gestureSettings,
|
||||||
|
centerPt,
|
||||||
|
lastCenterPt,
|
||||||
|
panByPt;
|
||||||
|
|
||||||
if ( !event.preventDefaultAction && this.viewport ) {
|
if ( !event.preventDefaultAction && this.viewport ) {
|
||||||
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
gestureSettings = this.gestureSettingsByDeviceType( event.pointerType );
|
||||||
if ( gestureSettings.pinchToZoom ) {
|
if ( gestureSettings.pinchToZoom ) {
|
||||||
var centerPt = this.viewport.pointFromPixel( event.center, true ),
|
centerPt = this.viewport.pointFromPixel( event.center, true );
|
||||||
lastCenterPt = this.viewport.pointFromPixel( event.lastCenter, true );
|
lastCenterPt = this.viewport.pointFromPixel( event.lastCenter, true );
|
||||||
|
panByPt = lastCenterPt.minus( centerPt );
|
||||||
|
if( !this.panHorizontal ) {
|
||||||
|
panByPt.x = 0;
|
||||||
|
}
|
||||||
|
if( !this.panVertical ) {
|
||||||
|
panByPt.y = 0;
|
||||||
|
}
|
||||||
this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true );
|
this.viewport.zoomBy( event.distance / event.lastDistance, centerPt, true );
|
||||||
this.viewport.panBy( lastCenterPt.minus( centerPt ), true );
|
this.viewport.panBy( panByPt, true );
|
||||||
this.viewport.applyConstraints();
|
this.viewport.applyConstraints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user