From f6cb2d8e766faf36994a5411e04378a68c7df2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Sun, 10 May 2020 18:31:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=BB=9A=E5=8A=A8=E7=BB=84?= =?UTF-8?q?=E4=BB=B6;=E7=AE=80=E5=8C=96=E8=A1=A8=E6=A0=BC=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scroll/index.wc | 22 +++++++++-- src/table/index.wc | 92 +++++++++------------------------------------ src/table/td.wc | 10 ++++- src/table/tr.wc | 8 ++-- 4 files changed, 49 insertions(+), 83 deletions(-) diff --git a/src/scroll/index.wc b/src/scroll/index.wc index 853eb8d..e1ec7f5 100644 --- a/src/scroll/index.wc +++ b/src/scroll/index.wc @@ -107,6 +107,8 @@ const IS_FF = !!window.sidebar /* */ export default class Scroll { props = { + thumbX: 0, + thumbY: 0, disabled: false, axis: 'xy' // 滚动方向, 默认x轴和y轴都可以滚动 } @@ -253,7 +255,7 @@ export default class Scroll { if (!xw && !yh) { return } - ev.preventDefault() + // ev.preventDefault() //校正兼容苹果鼠标在 chrome和FF下滚动的精度 var deltaX @@ -283,8 +285,12 @@ export default class Scroll { // 修正滚动条的位置 // 滚动比例 y 滚动条的可移动距离 var fixedY = (this.__BOX__.scrollTop / (sh - oh)) * (oh - yh) + fixedY = fixedY >> 0 this.props.thumbY = fixedY - + if (fixedY === 0 || oh - yh === fixedY) { + return + } + ev.preventDefault() this.__Y__.style.transform = `translateY(${fixedY}px)` } } @@ -296,11 +302,21 @@ export default class Scroll { // 修正滚动条的位置 // 滚动比例 x 滚动条的可移动距离 var fixedX = (this.__BOX__.scrollLeft / (sw - ow)) * (ow - xw) + fixedX = fixedX >> 0 this.props.thumbX = fixedX - + if (fixedX === 0 || ow - xw === fixedX) { + return + } + ev.preventDefault() this.__X__.style.transform = `translateX(${fixedX}px)` } } + + this.dispatchEvent( + new CustomEvent('scroll', { + detail: { x: this.props.thumbX, y: this.props.thumbY } + }) + ) }) var startX, diff --git a/src/table/index.wc b/src/table/index.wc index 52cd2cb..2962fb0 100644 --- a/src/table/index.wc +++ b/src/table/index.wc @@ -1,8 +1,8 @@ @@ -12,10 +12,6 @@ width: 100%; color: nth($cd, 1); } -ul, -li { - list-style: none; -} .table { overflow: hidden; flex: 1; @@ -30,60 +26,11 @@ li { user-select: none; -moz-user-select: none; } - - .tr { - display: flex; - height: 100%; - } - .td { - flex: 1; - display: flex; - align-items: center; - min-height: 36px; - border-right: 1px solid nth($cp, 3); - border-bottom: 1px solid nth($cp, 3); - - &.flex-2 { - flex: 2; - } - &.flex-3 { - flex: 3; - } - &.flex-4 { - flex: 4; - } - &.flex-5 { - flex: 5; - } - &.flex-6 { - flex: 6; - } - &.flex-7 { - flex: 7; - } - &.flex-8 { - flex: 8; - } - - &:last-child { - border-right: 0; - } - } - - .thead .td { - justify-content: center; - text-align: center; - } - - .cell { - padding: 3px 5px; - word-wrap: break-word; - word-break: break-all; - } }