weixin_39631301
2020-12-29 12:09 阅读 0

add threshold setting

Add threshold setting to move only if mouse moves farther than threshold. Threshold setting can be a function. fixes #83

该提问来源于开源项目:davetayls/jquery.kinetic

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

10条回答 默认 最新

  • weixin_39897449 weixin_39897449 2020-12-29 12:09

    Hi, a couple of thoughts on this.

    I'd prefer the threshold to work by keeping track of Start position and measuring against that at each step I think.

    Also, I know that sqrt isn't a particularly fast calculation. Whilst it's definitely more accurate it would be interesting to try and see if the experience works as well by just checking Y distance or X distance is greater than threshold relative to start position.

    Let me know your thoughts

    点赞 评论 复制链接分享
  • weixin_39897449 weixin_39897449 2020-12-29 12:09

    Alternatively if just counting down the threshold works better the property should probably be moveThresholdRemaining

    点赞 评论 复制链接分享
  • weixin_39897449 weixin_39897449 2020-12-29 12:09

    Please can you also update the read me and include a test with the threshold setting. Cheers

    点赞 评论 复制链接分享
  • weixin_39897449 weixin_39897449 2020-12-29 12:09

    Just add the test to the end of https://github.com/davetayls/jquery.kinetic/blob/master/test/specs/basic.spec.js 👌

    点赞 评论 复制链接分享
  • weixin_39631301 weixin_39631301 2020-12-29 12:09

    https://jsperf.com/sqrt-vs-abs

    I don't think Math.sqrt will affect the performance especially since it is being used before the scrolling occurs .

    I agree it should be from starting position. I will fix that and create the tests.

    点赞 评论 复制链接分享
  • weixin_39631301 weixin_39631301 2020-12-29 12:09

    Not sure why the build fails. The tests pass when viewing them in any browser. https://rawgit.com/UziTech/jquery.kinetic/master/test/specs/basic.html

    点赞 评论 复制链接分享
  • weixin_39897449 weixin_39897449 2020-12-29 12:09

    I'll take a look later this morning

    点赞 评论 复制链接分享
  • weixin_39897449 weixin_39897449 2020-12-29 12:09

    Just had a quick look on my phone and they aren't passing, is this because of the changes you have made to how the threshold works?

    点赞 评论 复制链接分享
  • weixin_39631301 weixin_39631301 2020-12-29 12:09

    found the bug in the dragOver() function for the tests. the touch move event was moving to x,x instead of x,y and the threshold wasn't being crossed

    点赞 评论 复制链接分享
  • weixin_39897449 weixin_39897449 2020-12-29 12:09

    thanks nice work, i'll merge this in and do a release :+1:

    点赞 评论 复制链接分享

相关推荐