Authored by 陈峰

品牌列表灵敏度

... ... @@ -4,7 +4,7 @@
<div class="index"><a :href="'#' + item.index" :id="item.index" :name="item.index">{{item.index}}</a></div>
<div class="brand-big-box clearfix">
<div class="brand-box" v-for="brand in item.brands" :key="brand.name">
<a v-brand-href="brand.domain">
<a v-brand-href="brand.domain" :class="hrefClass">
<span class="brand-name">{{brand.name}}</span>
</a>
</div>
... ... @@ -110,6 +110,7 @@
import bus from 'common/vue-bus';
import tip from 'common/tip';
import indexList from 'component/tool/index-list.vue';
import yoho from 'yoho';
export default {
props: ['channel'],
... ... @@ -118,6 +119,9 @@
brandList: [],
indexList: [],
currentChannel: this.channel,
hrefClass: {
'no-link': false
}
};
},
watch: {
... ... @@ -154,6 +158,43 @@
}
window.scrollTo(0, top);
}
},
touchmove() {
this.hrefClass['no-link'] = true;
},
touchend() {
this.hrefClass['no-link'] = false;
},
scrollEnd() {
this.hrefClass['no-link'] = false;
},
getScrollEventTarget(element) {
let getComputedStyle = document.defaultView.getComputedStyle;
let currentNode = element;
while (currentNode && currentNode.tagName !== 'HTML' && currentNode.tagName !== 'BODY' && currentNode.nodeType === 1) {
let overflowY = getComputedStyle(currentNode).overflowY;
if (overflowY === 'scroll' || overflowY === 'auto') {
return currentNode;
}
currentNode = currentNode.parentNode;
}
return window;
},
throttle(fn, delay) {
let timer;
return () => {
if (timer) {
clearTimeout(timer);
timer = null;
}
this.hrefClass['no-link'] = true;
timer = setTimeout(() => {
fn();
}, delay);
};
}
},
components: {
... ... @@ -165,6 +206,16 @@
this.currentChannel = channel;
this.getBrandList();
});
}
},
mounted() {
const $scrollEl = this.getScrollEventTarget(this.$el);
if (yoho.isiOS) {
$scrollEl.addEventListener('touchmove', this.touchmove);
$scrollEl.addEventListener('touchend', this.touchend);
} else {
$scrollEl.addEventListener('scroll', this.throttle(this.scrollEnd, 200));
}
},
};
</script>
... ...