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

View File

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