diff --git a/forces.html b/forces.html index 4b3dc77..770e10f 100644 --- a/forces.html +++ b/forces.html @@ -1097,6 +1097,14 @@ l
力是物体对物体的作用,力不能脱离物体 else vel = Math.min(0, vel + fricStep); } } + // 拖拽时按距光标的剩余距离限制速度,越接近光标限速越低, + // 避免速度过大冲过光标后弹簧反向拉回造成左右摆动 + if(dragging && moving){ + const pullNow = dragTargetX - (box.x + box.w / 2); + const limitV = Math.abs(pullNow) * 0.18 + 0.5; + if(vel > limitV) vel = limitV; + else if(vel < -limitV) vel = -limitV; + } if(moving){ box.x += vel * 0.016 * 60; if(box.x < 20){ box.x = 20; vel = 0; moving = false; }