¶Ô±ÈÐÂÎļþ |
| | |
| | | // å¼å
¥bindingxï¼æ¤åºç±»ä¼¼äºå¾®ä¿¡å°ç¨åºwxsï¼ç®çæ¯è®©jsè¿è¡å¨è§å¾å±ï¼åå°è§å¾å±åé»è¾å±çéä¿¡ææ |
| | | const BindingX = uni.requireNativePlugin('bindingx') |
| | | |
| | | export default { |
| | | methods: { |
| | | // æ¤å¤ä¸å注éï¼è¯·èªè¡ä½ä¼ |
| | | nvueScrollHandler(e) { |
| | | const anchor = this.$refs['u-scroll-list__scroll-view'].ref |
| | | const element = this.$refs['u-scroll-list__indicator__line__bar'].ref |
| | | const scrollLeft = e.contentOffset.x |
| | | const contentSize = e.contentSize.width |
| | | const { scrollWidth } = this |
| | | const barAllMoveWidth = this.indicatorWidth - this.indicatorBarWidth |
| | | // å¨å®ååiOSä¸ï¼éè¦é¤çåæ°ä¸ä¸æ ·ï¼iOSéè¦é¤ä»¥2 |
| | | const actionNum = uni.$u.os() === 'ios' ? 2 : 1 |
| | | const expression = `(x / ${actionNum}) / ${contentSize - scrollWidth} * ${barAllMoveWidth}` |
| | | BindingX.bind({ |
| | | anchor, |
| | | eventType: 'scroll', |
| | | props: [{ |
| | | element, |
| | | property: 'transform.translateX', |
| | | expression |
| | | }] |
| | | }) |
| | | } |
| | | } |
| | | } |