diff --git a/dist/iwmlib.js b/dist/iwmlib.js index c858c55..0cbf467 100644 --- a/dist/iwmlib.js +++ b/dist/iwmlib.js @@ -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; } } diff --git a/dist/iwmlib.pixi.js b/dist/iwmlib.pixi.js index 706334d..bc18fb1 100644 --- a/dist/iwmlib.pixi.js +++ b/dist/iwmlib.pixi.js @@ -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; } } diff --git a/lib/scatter.js b/lib/scatter.js index 107d3db..76de55e 100644 --- a/lib/scatter.js +++ b/lib/scatter.js @@ -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 } }