1. 程式人生 > >mint-UI上拉載入下拉重新整理和fastclick衝突問題解決

mint-UI上拉載入下拉重新整理和fastclick衝突問題解決

當我們的Vue專案為了解決IOS裝置事件點選卡頓,300ms的延遲的問題,引入了fastclick後,會有很多小的衝突,例如在使用mint-UI實現上拉載入和下拉重新整理的時候,經常會觸碰到點選事件進入下一個頁面,這是因為去掉300毫秒的延遲就會使得頁面特別靈敏,想著用阻止冒泡的方式來解決。

在/node_modules\mint-ui\lib\loadmore\index.js和mint-ui.common.js中handleTouchEnd: function handleTouchEnd(event) {...}中新增如下紅色程式碼:

if (this.direction === 'down' && this.getScrollTop(this.scrollEventTarget) === 0 && this.translate > 0) {

event.preventDefault();

event.stopPropagation();

 

if (this.direction === 'up' && this.bottomReached && this.translate < 0) {

event.preventDefault();

event.stopPropagation();