Moved the addVelocity method after the transform to allow a modification of the delta within the transform method. To make this destructive side effect more explicit transform could return a modified value. But that could effect several projects.

This commit is contained in:
Uwe Oestermeier 2021-04-28 17:02:54 +02:00
parent 266a770c8e
commit eff934e8b5
1 changed files with 22 additions and 23 deletions

View File

@ -44,8 +44,7 @@ const END = 'onEnd'
*/ */
export class ScatterEvent extends BaseEvent { export class ScatterEvent extends BaseEvent {
constructor( constructor(
target, target, { translate = { x: 0, y: 0 }, scale = null, rotate = 0, about = null, fast = false, type = null } = {}
{ translate = { x: 0, y: 0 }, scale = null, rotate = 0, about = null, fast = false, type = null } = {}
) { ) {
super('scatterTransformed', { target: target }) super('scatterTransformed', { target: target })
this.translate = translate this.translate = translate
@ -382,7 +381,7 @@ export class AbstractScatter extends Throwable {
let delta = interaction.delta() let delta = interaction.delta()
if (delta != null) { if (delta != null) {
this.addVelocity(delta) // uo: reverted commit fa0256d782dd498c6d3e51321260ca375ca9f855
let rotate = delta.rotate let rotate = delta.rotate
let zoom = delta.zoom let zoom = delta.zoom
if (this.maxRotation != null) { if (this.maxRotation != null) {
@ -403,6 +402,8 @@ export class AbstractScatter extends Throwable {
} }
this.transform(delta, zoom, rotate, delta.about) this.transform(delta, zoom, rotate, delta.about)
this.addVelocity(delta) // uo: reverted commit fa0256d782dd498c6d3e51321260ca375ca9f855
if (zoom != 1) this.interactionAnchor = delta.about if (zoom != 1) this.interactionAnchor = delta.about
} }
} }
@ -911,8 +912,7 @@ export class DOMScatterContainer {
* @param {DOM node} debugCanvas - Shows debug infos about touches if not null * @param {DOM node} debugCanvas - Shows debug infos about touches if not null
*/ */
constructor( constructor(
element, element, {
{
stopEvents = 'auto', stopEvents = 'auto',
claimEvents = true, claimEvents = true,
useCapture = true, useCapture = true,
@ -1076,8 +1076,7 @@ export class DOMScatterContainer {
export class DOMScatter extends AbstractScatter { export class DOMScatter extends AbstractScatter {
constructor( constructor(
element, element,
container, container, {
{
startScale = 1.0, startScale = 1.0,
minScale = 0.1, minScale = 0.1,
maxScale = 1.0, maxScale = 1.0,