From e9a66887ff873feb2734a1455273bb56df748ee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A6=95=E5=9F=8E=E5=B0=8F=E6=9E=97=E5=9B=9D?= Date: Thu, 4 Apr 2019 14:02:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?add=20handleWheel=20=E5=A2=9E=E5=8A=A0picke?= =?UTF-8?q?r=E5=8C=BA=E5=9F=9F=E9=BC=A0=E6=A0=87=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 鼠标事件 --- src/js/picker.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/js/picker.js b/src/js/picker.js index 557cee8..4df5889 100644 --- a/src/js/picker.js +++ b/src/js/picker.js @@ -370,12 +370,33 @@ var value = $(this).attr('data-picker-value'); col.setValue(value); } + + function handleWheel(e){ + allowItemClick = false; + $.cancelAnimationFrame(animationFrameId); + + var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) || (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1)); + var newPickerVal, valuecurrent, currentElement = $(col.items[col.activeIndex]); + newPickerVal = valuecurrent = currentElement.attr('data-picker-value'); + if(delta>0 && (col.activeIndex !== 0)){ + newPickerVal = currentElement.prev().attr('data-picker-value'); + }else if(delta<0 && (col.activeIndex !== (col.items.length-1))){ + newPickerVal = currentElement.next().attr('data-picker-value'); + } + (newPickerVal!=valuecurrent)&&col.setValue(newPickerVal); + + // Allow click + setTimeout(function () { + allowItemClick = true; + }, 100); + } col.initEvents = function (detach) { var method = detach ? 'off' : 'on'; col.container[method]($.touchEvents.start, handleTouchStart); col.container[method]($.touchEvents.move, handleTouchMove); col.container[method]($.touchEvents.end, handleTouchEnd); + col.container[method]("wheel mousewheel DOMMouseScroll", handleWheel); col.items[method]('click', handleClick); }; col.destroyEvents = function () { @@ -635,6 +656,8 @@ dialog.width(); //通过取一次CSS值,强制浏览器不能把上下两行代码合并执行,因为合并之后会导致无法出现动画。 dialog.addClass("weui-picker-modal-visible"); + + dialog[0].addEventListener('mousewheel',function(e){e.preventDefault();}); //picker选项区域禁止鼠标滚动 callback && container.on("close", callback); From a22f3f4521844e6e16ba665540ac340b2fbb1aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A6=95=E5=9F=8E=E5=B0=8F=E6=9E=97=E5=9B=9D?= Date: Tue, 21 May 2019 14:40:38 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=B9=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/photos.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/photos.js b/src/js/photos.js index 6520b23..582dfab 100644 --- a/src/js/photos.js +++ b/src/js/photos.js @@ -51,8 +51,6 @@ } var self = this; - this.modal.show().height(); - this.modal.addClass('weui-photo-browser-modal-visible'); this.container.addClass('swiper-container-visible').transitionEnd(function() { self.initParams(); if(index !== undefined) { @@ -62,6 +60,8 @@ self.config.onOpen.call(self); } }); + this.modal.show().height(); + this.modal.addClass('weui-photo-browser-modal-visible'); this._open = true; },