首页 > 解决方案 > 如何知道指针在离子角范围分量中是向左还是向右

问题描述

我不知道是否有办法在离子范围组件上找到指针方向。我的意思是指针是向左还是向右?

谢谢你的帮助

标签: angularionic-frameworkionic3angular-components

解决方案


好的,这是你可以做到的:

https://stackblitz.com/edit/ionic-qnxrnv

基本上你有你的范围(我使用默认值,即 0 到 100 个值):

然后你绑定方法来检测运动:

sliderValueChanged(event) {
    // if current slider value exist we can do comparision:
    if (this.currentSliderValue && (this.currentSliderValue > event.value)) {
      console.log("moving left");
    } else {
      console.log("moving right")
    }
    // now we capture result
    this.currentSliderValue = event.value
  }

根据您的用例,您可能需要考虑值等于等时的不同情况


推荐阅读