|
3021 | 3021 | this.velocityY = 0;
|
3022 | 3022 | }
|
3023 | 3023 | else if (phase === 'inertiastart') {
|
3024 |
| - this.timeStamp = new Date().getTime(); |
| 3024 | + this.timeStamp = interaction.prevEvent.timeStamp; |
3025 | 3025 | this.dt = interaction.prevEvent.dt;
|
3026 | 3026 | this.duration = interaction.prevEvent.duration;
|
3027 | 3027 | this.speed = interaction.prevEvent.speed;
|
|
3033 | 3033 | this.dt = this.timeStamp - interaction.prevEvent.timeStamp;
|
3034 | 3034 | this.duration = this.timeStamp - interaction.downTime;
|
3035 | 3035 |
|
3036 |
| - var dx, dy, dt; |
3037 |
| - |
3038 |
| - // Use natural event coordinates (without snapping/restricions) |
3039 |
| - // subtract modifications from previous event if event given is |
3040 |
| - // not a native event |
3041 | 3036 | if (event instanceof InteractEvent) {
|
3042 |
| - // change in time in seconds |
3043 |
| - // use event sequence duration for end events |
3044 |
| - // => average speed of the event sequence |
3045 |
| - // (minimum dt of 1ms) |
3046 |
| - dt = Math.max((ending? this.duration: this.dt) / 1000, 0.001); |
3047 |
| - dx = this[sourceX] - interaction.prevEvent[sourceX]; |
3048 |
| - dy = this[sourceY] - interaction.prevEvent[sourceY]; |
3049 |
| - |
3050 |
| - if (this.snap && this.snap.locked) { |
3051 |
| - dx -= this.snap.dx; |
3052 |
| - dy -= this.snap.dy; |
3053 |
| - } |
| 3037 | + var dx = this[sourceX] - interaction.prevEvent[sourceX], |
| 3038 | + dy = this[sourceY] - interaction.prevEvent[sourceY], |
| 3039 | + dt = this.dt / 1000; |
3054 | 3040 |
|
3055 |
| - if (this.restrict) { |
3056 |
| - dx -= this.restrict.dx; |
3057 |
| - dy -= this.restrict.dy; |
3058 |
| - } |
3059 |
| - |
3060 |
| - if (interaction.prevEvent.snap && interaction.prevEvent.snap.locked) { |
3061 |
| - dx -= (interaction.prevEvent[sourceX] - interaction.prevEvent.snap.dx); |
3062 |
| - dy -= (interaction.prevEvent[sourceY] - interaction.prevEvent.snap.dy); |
3063 |
| - } |
3064 |
| - |
3065 |
| - if (interaction.prevEvent.restrict) { |
3066 |
| - dx += interaction.prevEvent.restrict.dx; |
3067 |
| - dy += interaction.prevEvent.restrict.dy; |
3068 |
| - } |
3069 |
| - |
3070 |
| - // speed and velocity in pixels per second |
3071 | 3041 | this.speed = hypot(dx, dy) / dt;
|
3072 | 3042 | this.velocityX = dx / dt;
|
3073 | 3043 | this.velocityY = dy / dt;
|
3074 | 3044 | }
|
3075 |
| - // if normal move event, use previous user event coords |
| 3045 | + // if normal move or end event, use previous user event coords |
3076 | 3046 | else {
|
| 3047 | + // speed and velocity in pixels per second |
3077 | 3048 | this.speed = interaction.pointerDelta[deltaSource].speed;
|
3078 | 3049 | this.velocityX = interaction.pointerDelta[deltaSource].vx;
|
3079 | 3050 | this.velocityY = interaction.pointerDelta[deltaSource].vy;
|
|
0 commit comments