'How to use JavaScript create a damping function?

I'm writing a scrollbar plugin. When dragging, I want to simulate the function of Safari(IOS), that is, overflow is allowed after dragging to the edge. In fact, Safari (IOS) has an edge decreasing effect when dragging, that is, it will become more and more immobile. This effect seems to be realized by damping function ? I tried to search, but I didn't find a particularly suitable function. I found some relevant contents in this article : How UIScrollView works, but I don't understand OC and Swift, and I'm not very good at math. Can anyone help me. ಥ_ಥ

Here is the damping function provided by another article : drag damping, but in fact, it uses a piecewise function to achieve the damping effect. Although it will be faster, it is found after the test that it does not meet my needs. I hope to set the maximum target value clearly, but in this function, it cannot explicitly control the maximum value.

This is a screenshot of the project. At present, the dragged part has not been completed, but the wheel control part has been realized, and the overflow can also be realized. However, because there is no appropriate damping function, the increment after overflow seems very rigid.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source