tarun-dugar / easy-scroll

A lightweight native javascript library to perform smooth scrolling with animation
MIT License
121 stars 11 forks source link

Invalid cubic bezier formula #10

Open tmaxmax opened 4 years ago

tmaxmax commented 4 years ago

Something I have noticed is that the formula you use for determining the Bezier easing percentage isn't valid.

The formula finds either the horizontal or vertical coordinate of a point on the Cubic Bezier curve. Although it is correct, you are mixing the coordinates, using both coordinates of the control points, instead of only one. This error results in an incorrect completion percentage of the animation.

I would suggest using a separate implementation of the Cubic Bezier easing curves if you wish to keep this feature or use only the timing functions for easing.

PASHANSX commented 4 years ago

+++

var config = {
        'scrollableDomEle': window,
    'duration': 1500,
    'direction': "bottom",
    'scrollAmount': 1400,
    'cubicBezierPoints': {
        'x1': 0.42,
        'y1': 0,
        'x2': 0.58,
        'y2': 1
    }
};
tarundugar commented 4 years ago

will check on this, thanks!