From 0234144dfbfd21db24b1ba7cc8f9f960f8d35f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Thu, 30 Jul 2020 15:29:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E7=BB=84=E4=BB=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=BF=BB=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/neditor/index.wc | 7 ------- src/scroll/index.wc | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/neditor/index.wc b/src/neditor/index.wc index 25d2915..bbb0b41 100644 --- a/src/neditor/index.wc +++ b/src/neditor/index.wc @@ -331,13 +331,6 @@ export default class Neditor { return } - log( - this.__EDITOR__, - '------', - val, - (type === 'boolean' && val) || type !== 'boolean' - ) - if ((type === 'boolean' && val) || type !== 'boolean') { this.props.disabled = true this.setAttribute('disabled', '') diff --git a/src/scroll/index.wc b/src/scroll/index.wc index 597d397..487d00b 100644 --- a/src/scroll/index.wc +++ b/src/scroll/index.wc @@ -243,6 +243,10 @@ export default class Scroll { this.__Y__.style.height = yh + 'px' }) + this._inactiveFn = $.bind(this.__BOX__, 'mouseleave', ev => { + delete this._active + }) + // 鼠标滚动事件 this._wheelFn = $.bind(this.__BOX__, 'wheel', ev => { // 禁用状态, 不允许滚动 @@ -343,6 +347,8 @@ export default class Scroll { } } + this._active = true + this.stamp = now this.dispatchEvent( new CustomEvent('scroll', { @@ -362,6 +368,7 @@ export default class Scroll { } if (startY !== null) { + this._active = true moveY = this._fetchScrollY(thumbY + ev.pageY - startY) } }, @@ -400,6 +407,27 @@ export default class Scroll { $.bind(document, 'mouseup', mouseupFn) }) + $.catch(document, 'keydown', ev => { + if (this._active) { + var { oh, sh } = this.props + switch (ev.keyCode) { + case 33: // pageUp + this.scrollTop -= oh + break + case 34: // pageDown + this.scrollTop += oh + break + case 35: // End + this.scrollTop = sh + break + case 36: // Home + this.scrollTop = 0 + break + } + ev.preventDefault() + } + }) + this.__observer = new MutationObserver(this._initFn) this.__observer.observe(this, { childList: true, @@ -410,7 +438,9 @@ export default class Scroll { unmount() { this.__observer.disconnect() + $.unbind(this.__BOX__, 'mouseenter', this._initFn) + $.unbind(this.__BOX__, 'mouseleave', this._inactiveFn) $.unbind(this.__BOX__, 'wheel', this._wheelFn) }