diff --git a/static/js/background_anim.js b/static/js/background_anim.js index f835fdb857424efa2ac3f4f175dc897f7b74e518..2a78cb654729b107d0f02f349a98d8d5a0caff11 100644 --- a/static/js/background_anim.js +++ b/static/js/background_anim.js @@ -235,11 +235,19 @@ const physics = () => { dot.xy *= VELOCITY_SLOWDOWN_MULTIPLIER; // Stop velocity from going below initial velocity - if(dot.vx < dot.initial_vx) { - dot.vx = dot.initial_vx; + if(Math.abs(dot.vx) < Math.abs(dot.initial_vx)) { + if((dot.vx > 0 && dot.initial_vx > 0) || (dot.vx < 0 && dot.initial_vx < 0)) { + dot.vx = dot.initial_vx; + } else { + dot.vx = -dot.initial_vx; + } } - if(dot.vy < dot.initial_vy) { - dot.vy = dot.initial_vy; + if(Math.abs(dot.vy) < Math.abs(dot.initial_vy)) { + if((dot.vy > 0 && dot.initial_vy > 0) || (dot.vy < 0 && dot.initial_vy < 0)) { + dot.vy = dot.initial_vy; + } else { + dot.vy = -dot.initial_vy; + } } // Invert velocities if off-screen and not already inverted