Browse Source

优化商品分类选中效果

feature/feature-compatible
wenghaocan 7 years ago
parent
commit
026abc452f
1 changed files with 37 additions and 3 deletions
  1. 40
      src/view/goods-classify.vue

40
src/view/goods-classify.vue

@ -61,11 +61,12 @@
goodsList: [],
imghost: "http://medou.oss-cn-shenzhen.aliyuncs.com/",
listHeight: [], //
scrollY: {}
scrollY: {},
currentNum: 0
}
},
computed: {
currentIndex () {
/*currentIndex () {
const { scrollY, listHeight } = this
let index = listHeight.findIndex((height, index) => {
return scrollY >= listHeight[index] && scrollY < listHeight[index + 1]
@ -74,6 +75,26 @@
index++
}
return index
}*/
currentIndex(){
for (let i = 0; i < this.listHeight.length; i++){
let height = this.listHeight[i]
let height2 = this.listHeight[i + 1]
//height2heightheight2
//>=height,this.scrollY=0,height=0
if( !height2 || (this.scrollY >= height && this.scrollY < height2)) {
return i
}
if(this.listHeight[this.listHeight.length-1] - this.$refs.foodWrapper.clientHeight <= this.scrollY ) {
if(this.clickTrue) {
return this.currentNum
} else {
return (this.listHeight.length-1)
}
}
}
return 0
}
},
components: {
@ -152,13 +173,26 @@
this.listHeight.push(height);
}
},
selectMenu(index, event) {
/*selectMenu(index, event) {
if(event && !event._constructed) {
return ;
}
let foodList = this.$refs.foodWrapper.getElementsByClassName("food-list-hook");
let el = foodList[index];
this.foodsScroll.scrollToElement(el,300)
},*/
selectMenu(index, event){
this.clickTrue = true //clickTruetrue
this.currentNum = index
//better-scrolleventevent_constructed
// _constructedreturn
if (event && !event._constructed){
return
} else {
let foodList = this.$refs.foodWrapper.getElementsByClassName("food-list-hook");
let el = foodList[index];
this.foodsScroll.scrollToElement(el,300)
}
},
autoSelect() {
for (let i = 0; i < this.goodsList.length; i++) {

Loading…
Cancel
Save