Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,怎么调整下拉时的阻尼系数,看了源码,没有发现这个变量的设置 #9

Closed
sj8521123 opened this issue Feb 10, 2017 · 8 comments

Comments

@sj8521123
Copy link

No description provided.

@lucklygaj
Copy link
Contributor

你好,在这里设置的

    // y = x - (x/2)^2
    float extraOS = nextOffsetTop - totalDragDistance;
    float slingshotDist = totalDragDistance;
    float tensionSlingshotPercent = Math.max(0, Math.min(extraOS, slingshotDist * 2) / slingshotDist);
    float tensionPercent = (float) (tensionSlingshotPercent - Math.pow(tensionSlingshotPercent / 2, 2));

    if (offset > 0) { // 下拉的时候才添加阻力
        offset = (int) (offset * (1f - tensionPercent));
        nextOffsetTop = Math.max(0, currentOffsetTop + offset);
    }

希望能帮到你

@sj8521123
Copy link
Author

能不能提供现有一个接口或者方法出来修改下拉的阻尼系数,因为我是直接用的gradle方式加载的库,不然只有把你的库手动导入进来修改。

@lucklygaj
Copy link
Contributor

可以的

@lucklygaj
Copy link
Contributor

已在1.1.4的版本中增加,感谢您的反馈

@sj8521123
Copy link
Author

谢谢

@sj8521123
Copy link
Author

打扰了,更新了1.1.4 发现有个setPUll_RESISTANCE(),但是设置任何double值都阻尼没变化,还有这个方法名能不能小写,public static void setPUll_RESISTANCE(double PUll_RESISTANCE) {
PUll_RESISTANCE = PUll_RESISTANCE;
}
是不是应该写成 this.PUll_RESISTANCE = PUll_RESISTANCE;

@lucklygaj
Copy link
Contributor

PUll_RESISTANCE 是属于static的,我改成对象的了,公式是y = x - (x/a)^2 a是PUll_RESISTANCE 这阻尼滑动效果我也是参考网上一位大神的,1.1.5已修改,希望对你有帮助

@lucklygaj
Copy link
Contributor

你看下,如果有需要的话,我暴露个返回最终y值的接口出来给你,里面的阻尼公示由你们来定义

@lucklygaj lucklygaj reopened this Mar 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants