综合办公系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nvue.js 1.0KB

1234567891011121314151617181920212223242526272829
  1. // 引入bindingx,此库类似于微信小程序wxs,目的是让js运行在视图层,减少视图层和逻辑层的通信折损
  2. const BindingX = uni.requireNativePlugin('bindingx')
  3. export default {
  4. methods: {
  5. // 此处不写注释,请自行体会
  6. nvueScrollHandler(e) {
  7. if (this.indicator) {
  8. const anchor = this.$refs['uv-scroll-list__scroll-view'].ref
  9. const element = this.$refs['uv-scroll-list__indicator__line__bar'].ref
  10. const scrollLeft = e.contentOffset.x
  11. const contentSize = e.contentSize.width
  12. const { scrollWidth } = this
  13. const barAllMoveWidth = this.indicatorWidth - this.indicatorBarWidth
  14. // 在安卓和iOS上,需要除的倍数不一样,iOS需要除以2
  15. const actionNum = this.$uv.os() === 'ios' ? 2 : 1
  16. const expression = `(x / ${actionNum}) / ${contentSize - scrollWidth} * ${this.$uv.getPx(this.$uv.addUnit(barAllMoveWidth))}`
  17. BindingX.bind({
  18. anchor,
  19. eventType: 'scroll',
  20. props: [{
  21. element,
  22. property: 'transform.translateX',
  23. expression
  24. }]
  25. })
  26. }
  27. }
  28. }
  29. }