Added maxRotation parameter.

This commit is contained in:
Uwe Oestermeier 2019-07-04 16:00:56 +02:00
parent 6e4e847be1
commit dda6262601
3 changed files with 36 additions and 9 deletions

15
dist/iwmlib.js vendored
View File

@ -3135,7 +3135,8 @@
onThrowFinished = null,
scaleAutoClose = false,
scaleCloseThreshold = 0.10,
scaleCloseBuffer = 0.05
scaleCloseBuffer = 0.05,
maxRotation = 5
} = {}) {
if (rotationDegrees != null && rotation != null) {
throw new Error('Use rotationDegrees or rotation but not both')
@ -3167,6 +3168,7 @@
this.startScale = startScale; // Needed to reset object
this.minScale = minScale;
this.maxScale = maxScale;
this.maxRotation = maxRotation;
this.overdoScaling = overdoScaling;
this.translatable = translatable;
if (!translatable) {
@ -3178,6 +3180,7 @@
this.resizable = resizable;
this.mouseZoomFactor = mouseZoomFactor;
this.autoBringToFront = autoBringToFront;
this.dragging = false;
this.onTransform = onTransform != null ? [onTransform] : null;
this.onClose = onClose != null ? [onClose] : null;
@ -3212,10 +3215,16 @@
gesture(interaction) {
let delta = interaction.delta();
//console.log("gesture", delta)
console.log("gesture", delta.rotate);
if (delta != null) {
this.addVelocity(delta);
this.transform(delta, delta.zoom, delta.rotate, delta.about);
let alpha = delta.rotate;
if (this.maxRotationPerStep != null) {
if (Math.abs(alpha) > this.maxRotationPerStep) {
alpha = 0;
}
}
this.transform(delta, delta.zoom, alpha, delta.about);
if (delta.zoom != 1) this.interactionAnchor = delta.about;
}
}

15
dist/iwmlib.pixi.js vendored
View File

@ -6302,7 +6302,8 @@
onThrowFinished = null,
scaleAutoClose = false,
scaleCloseThreshold = 0.10,
scaleCloseBuffer = 0.05
scaleCloseBuffer = 0.05,
maxRotation = 5
} = {}) {
if (rotationDegrees != null && rotation != null) {
throw new Error('Use rotationDegrees or rotation but not both')
@ -6334,6 +6335,7 @@
this.startScale = startScale; // Needed to reset object
this.minScale = minScale;
this.maxScale = maxScale;
this.maxRotation = maxRotation;
this.overdoScaling = overdoScaling;
this.translatable = translatable;
if (!translatable) {
@ -6345,6 +6347,7 @@
this.resizable = resizable;
this.mouseZoomFactor = mouseZoomFactor;
this.autoBringToFront = autoBringToFront;
this.dragging = false;
this.onTransform = onTransform != null ? [onTransform] : null;
this.onClose = onClose != null ? [onClose] : null;
@ -6379,10 +6382,16 @@
gesture(interaction) {
let delta = interaction.delta();
//console.log("gesture", delta)
console.log("gesture", delta.rotate);
if (delta != null) {
this.addVelocity(delta);
this.transform(delta, delta.zoom, delta.rotate, delta.about);
let alpha = delta.rotate;
if (this.maxRotationPerStep != null) {
if (Math.abs(alpha) > this.maxRotationPerStep) {
alpha = 0;
}
}
this.transform(delta, delta.zoom, alpha, delta.about);
if (delta.zoom != 1) this.interactionAnchor = delta.about;
}
}

View File

@ -268,7 +268,8 @@ export class AbstractScatter extends Throwable {
onThrowFinished = null,
scaleAutoClose = false,
scaleCloseThreshold = 0.10,
scaleCloseBuffer = 0.05
scaleCloseBuffer = 0.05,
maxRotation = 5
} = {}) {
if (rotationDegrees != null && rotation != null) {
throw new Error('Use rotationDegrees or rotation but not both')
@ -300,6 +301,7 @@ export class AbstractScatter extends Throwable {
this.startScale = startScale // Needed to reset object
this.minScale = minScale
this.maxScale = maxScale
this.maxRotation = maxRotation
this.overdoScaling = overdoScaling
this.translatable = translatable
if (!translatable) {
@ -311,6 +313,7 @@ export class AbstractScatter extends Throwable {
this.resizable = resizable
this.mouseZoomFactor = mouseZoomFactor
this.autoBringToFront = autoBringToFront
this.dragging = false
this.onTransform = onTransform != null ? [onTransform] : null
this.onClose = onClose != null ? [onClose] : null
@ -345,10 +348,16 @@ export class AbstractScatter extends Throwable {
gesture(interaction) {
let delta = interaction.delta()
//console.log("gesture", delta)
console.log("gesture", delta.rotate)
if (delta != null) {
this.addVelocity(delta)
this.transform(delta, delta.zoom, delta.rotate, delta.about)
let alpha = delta.rotate
if (this.maxRotationPerStep != null) {
if (Math.abs(alpha) > this.maxRotationPerStep) {
alpha = 0
}
}
this.transform(delta, delta.zoom, alpha, delta.about)
if (delta.zoom != 1) this.interactionAnchor = delta.about
}
}