@websy/websy-designs 1.7.4 → 1.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/websy-designs-es6.debug.js +130 -4
- package/dist/websy-designs-es6.js +276 -129
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +130 -4
- package/dist/websy-designs.js +276 -129
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -6435,6 +6435,7 @@ class WebsyTable3 {
|
|
|
6435
6435
|
minusIcon: WebsyDesigns.Icons.MinusFilled
|
|
6436
6436
|
}
|
|
6437
6437
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
6438
|
+
this.isTouchDevice = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)
|
|
6438
6439
|
this.sizes = {}
|
|
6439
6440
|
this.currentData = []
|
|
6440
6441
|
this.scrollDragging = false
|
|
@@ -6469,6 +6470,7 @@ class WebsyTable3 {
|
|
|
6469
6470
|
<div id="${this.elementId}_hScrollContainer" class="websy-h-scroll-container">
|
|
6470
6471
|
<div id="${this.elementId}_hScrollHandle" class="websy-scroll-handle websy-scroll-handle-x"></div>
|
|
6471
6472
|
</div>
|
|
6473
|
+
<div id="${this.elementId}_touchScroller" class="websy-table-touch-scroller hidden"></div>
|
|
6472
6474
|
</div>
|
|
6473
6475
|
<div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
|
|
6474
6476
|
<div>
|
|
@@ -6476,7 +6478,7 @@ class WebsyTable3 {
|
|
|
6476
6478
|
<div id="${this.elementId}_errorMessage"></div>
|
|
6477
6479
|
</div>
|
|
6478
6480
|
</div>
|
|
6479
|
-
<div id="${this.elementId}_dropdownContainer"></div>
|
|
6481
|
+
<div id="${this.elementId}_dropdownContainer" class="table-dropdown-container"></div>
|
|
6480
6482
|
<div id="${this.elementId}_loadingContainer"></div>
|
|
6481
6483
|
</div>
|
|
6482
6484
|
`
|
|
@@ -6491,6 +6493,9 @@ class WebsyTable3 {
|
|
|
6491
6493
|
el.innerHTML = html
|
|
6492
6494
|
el.addEventListener('click', this.handleClick.bind(this))
|
|
6493
6495
|
el.addEventListener('mousedown', this.handleMouseDown.bind(this))
|
|
6496
|
+
el.addEventListener('touchstart', this.handleTouchStart.bind(this))
|
|
6497
|
+
window.addEventListener('touchmove', this.handleTouchMove.bind(this))
|
|
6498
|
+
window.addEventListener('touchend', this.handleTouchEnd.bind(this))
|
|
6494
6499
|
window.addEventListener('mousemove', this.handleMouseMove.bind(this))
|
|
6495
6500
|
window.addEventListener('mouseup', this.handleMouseUp.bind(this))
|
|
6496
6501
|
let scrollEl = document.getElementById(`${this.elementId}_tableBody`)
|
|
@@ -6549,7 +6554,8 @@ class WebsyTable3 {
|
|
|
6549
6554
|
data.forEach((row, rowIndex) => {
|
|
6550
6555
|
bodyHtml += `<tr class="websy-table-row">`
|
|
6551
6556
|
row.forEach((cell, cellIndex) => {
|
|
6552
|
-
let sizeIndex = cell.level || cellIndex
|
|
6557
|
+
let sizeIndex = cell.level || cellIndex
|
|
6558
|
+
let colIndex = cell.index || cellIndex
|
|
6553
6559
|
if (typeof sizingColumns[sizeIndex] === 'undefined' || sizingColumns[sizeIndex].show === false) {
|
|
6554
6560
|
return // need to revisit this logic
|
|
6555
6561
|
}
|
|
@@ -6584,7 +6590,7 @@ class WebsyTable3 {
|
|
|
6584
6590
|
rowspan='${cell.rowspan || 1}'
|
|
6585
6591
|
data-row-index='${rowIndex}'
|
|
6586
6592
|
data-cell-index='${cellIndex}'
|
|
6587
|
-
data-col-index='${
|
|
6593
|
+
data-col-index='${colIndex}'
|
|
6588
6594
|
`
|
|
6589
6595
|
// if (useWidths === true) {
|
|
6590
6596
|
// bodyHtml += `
|
|
@@ -6598,7 +6604,7 @@ class WebsyTable3 {
|
|
|
6598
6604
|
class='websy-table-cell-content'
|
|
6599
6605
|
data-row-index='${rowIndex}'
|
|
6600
6606
|
data-cell-index='${cellIndex}'
|
|
6601
|
-
data-col-index='${
|
|
6607
|
+
data-col-index='${colIndex}'
|
|
6602
6608
|
>`
|
|
6603
6609
|
if (cell.expandable === true) {
|
|
6604
6610
|
bodyHtml += `<i
|
|
@@ -6960,6 +6966,9 @@ class WebsyTable3 {
|
|
|
6960
6966
|
}
|
|
6961
6967
|
}
|
|
6962
6968
|
handleMouseDown (event) {
|
|
6969
|
+
if (this.isTouchDevice === true) {
|
|
6970
|
+
return
|
|
6971
|
+
}
|
|
6963
6972
|
if (event.target.classList.contains('websy-scroll-handle-y')) {
|
|
6964
6973
|
// set up the scroll start values
|
|
6965
6974
|
this.scrollDragging = true
|
|
@@ -7007,8 +7016,89 @@ class WebsyTable3 {
|
|
|
7007
7016
|
this.scrollX(Math.max(-5, Math.min(5, event.deltaX)))
|
|
7008
7017
|
}
|
|
7009
7018
|
else {
|
|
7019
|
+
console.log('delta', event.deltaY)
|
|
7010
7020
|
this.scrollY(Math.max(-5, Math.min(5, event.deltaY)))
|
|
7011
7021
|
}
|
|
7022
|
+
}
|
|
7023
|
+
else if (this.options.onNativeScroll) {
|
|
7024
|
+
const el = document.getElementById(`${this.elementId}_tableBody`)
|
|
7025
|
+
this.options.onNativeScroll(el.scrollTop)
|
|
7026
|
+
}
|
|
7027
|
+
}
|
|
7028
|
+
handleTouchEnd (event) {
|
|
7029
|
+
console.log('touch end fired')
|
|
7030
|
+
if (typeof event.targetTouches !== 'undefined') {
|
|
7031
|
+
this.isTouchScrolling = false
|
|
7032
|
+
this.touchEndTime = (new Date()).getTime()
|
|
7033
|
+
this.isPerpetual = true
|
|
7034
|
+
// this.perpetualScroll()
|
|
7035
|
+
this.touchStartTime = null
|
|
7036
|
+
const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
|
|
7037
|
+
touchScrollEl.classList.add('hidden')
|
|
7038
|
+
}
|
|
7039
|
+
}
|
|
7040
|
+
handleTouchMove (event) {
|
|
7041
|
+
console.log(event.target.classList)
|
|
7042
|
+
if (this.isTouchScrolling === true) {
|
|
7043
|
+
event.preventDefault()
|
|
7044
|
+
event.stopPropagation()
|
|
7045
|
+
if (typeof event.targetTouches !== 'undefined' && event.targetTouches.length > 0) {
|
|
7046
|
+
let deltaX = (this.mouseXStart - event.targetTouches[0].pageX)
|
|
7047
|
+
let deltaY = (this.mouseYStart - event.targetTouches[0].pageY)
|
|
7048
|
+
// need to adjust the delta so that it scrolls at a reasonable speed/distance
|
|
7049
|
+
const scrollHandleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
7050
|
+
const scrollHandleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
7051
|
+
// if (Math.abs(deltaY) > this.sizes.cellHeight) {
|
|
7052
|
+
// this.isTouchScrolling = true
|
|
7053
|
+
// }
|
|
7054
|
+
// else {
|
|
7055
|
+
// this.isTouchScrolling = false
|
|
7056
|
+
// }
|
|
7057
|
+
console.log('delta init', deltaY)
|
|
7058
|
+
// deltaX = deltaX * (scrollHandleXEl.offsetWidth / this.sizes.scrollableWidth)
|
|
7059
|
+
// deltaY = deltaY * (scrollHandleYEl.offsetHeight / this.sizes.bodyHeight)
|
|
7060
|
+
// console.log('delta', deltaY)
|
|
7061
|
+
// NW
|
|
7062
|
+
// else if (Math.abs(deltaX) > 50) {
|
|
7063
|
+
// this.isTouchScrolling = false
|
|
7064
|
+
// }
|
|
7065
|
+
this.currentClientY = event.targetTouches[0].pageY
|
|
7066
|
+
this.currentTouchtime = (new Date()).getTime()
|
|
7067
|
+
// end
|
|
7068
|
+
// delta = Math.min(10, delta)
|
|
7069
|
+
// delta = Math.max(-10, delta)
|
|
7070
|
+
if (this.isTouchScrolling === true) {
|
|
7071
|
+
// this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 250)))
|
|
7072
|
+
if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 10) {
|
|
7073
|
+
this.scrollX(Math.max(-5, Math.min(5, deltaX)))
|
|
7074
|
+
}
|
|
7075
|
+
else {
|
|
7076
|
+
this.scrollY(Math.max(-5, Math.min(5, deltaY)))
|
|
7077
|
+
}
|
|
7078
|
+
}
|
|
7079
|
+
}
|
|
7080
|
+
}
|
|
7081
|
+
}
|
|
7082
|
+
handleTouchStart (event) {
|
|
7083
|
+
if (event.target.classList.contains('websy-table-cell-expand')) {
|
|
7084
|
+
return
|
|
7085
|
+
}
|
|
7086
|
+
if (event.target.classList.contains('websy-table-cell-collapse')) {
|
|
7087
|
+
return
|
|
7088
|
+
}
|
|
7089
|
+
console.log(event.target.classList)
|
|
7090
|
+
if (this.options.virtualScroll === true) {
|
|
7091
|
+
this.touchStartTime = (new Date()).getTime()
|
|
7092
|
+
this.isTouchScrolling = true
|
|
7093
|
+
this.isPerpetual = false
|
|
7094
|
+
this.mouseYStart = event.targetTouches[0].pageY
|
|
7095
|
+
this.mouseXStart = event.targetTouches[0].pageX
|
|
7096
|
+
const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
|
|
7097
|
+
touchScrollEl.classList.remove('hidden')
|
|
7098
|
+
const handleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
7099
|
+
this.handleYStart = handleYEl.offsetTop
|
|
7100
|
+
const handleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
7101
|
+
this.handleXStart = handleXEl.offsetLeft
|
|
7012
7102
|
}
|
|
7013
7103
|
}
|
|
7014
7104
|
hideError () {
|
|
@@ -7028,6 +7118,41 @@ class WebsyTable3 {
|
|
|
7028
7118
|
hideLoading () {
|
|
7029
7119
|
this.loadingDialog.hide()
|
|
7030
7120
|
}
|
|
7121
|
+
perpetualScroll () {
|
|
7122
|
+
// if the currentTouchtime and touchEndTime are more than 300ms apart then we abort the perpetual scroll
|
|
7123
|
+
if (this.touchEndTime - this.currentTouchtime > 300) {
|
|
7124
|
+
return
|
|
7125
|
+
}
|
|
7126
|
+
// get the difference in time between when the touch initially started and when it ended
|
|
7127
|
+
// the longer the touch duration, the slower the scroll
|
|
7128
|
+
let touchDuration = this.touchEndTime - this.touchStartTime
|
|
7129
|
+
// get the distance moved between when the touch initially started and when it ended
|
|
7130
|
+
let touchDistance = this.currentClientY - this.mouseYStart
|
|
7131
|
+
// the bigger the distance, the more we scroll
|
|
7132
|
+
// use the duration and distance to calculate the duration of the perpetual scroll
|
|
7133
|
+
let perpetualDistance = Math.abs(touchDistance * (1 / (touchDuration / 1000)))
|
|
7134
|
+
let perpetualDuration = touchDuration * 1.5 / 1000
|
|
7135
|
+
let requiredFrames = Math.abs(Math.ceil(perpetualDistance / this.sizes.cellHeight))
|
|
7136
|
+
let fps = requiredFrames / perpetualDuration
|
|
7137
|
+
let direction = touchDistance > 0 ? -1 : 1
|
|
7138
|
+
for (let i = 0; i < requiredFrames; i++) {
|
|
7139
|
+
setTimeout(() => {
|
|
7140
|
+
let delta = (this.mouseYStart - this.currentClientY + (this.sizes.cellHeight * (i + 1)) * direction)
|
|
7141
|
+
delta = Math.min(10, delta)
|
|
7142
|
+
delta = Math.max(-10, delta)
|
|
7143
|
+
// only run this if isPerpetual === true
|
|
7144
|
+
// this value is reset to false on touchStart
|
|
7145
|
+
if (this.isPerpetual === true) {
|
|
7146
|
+
// this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 250)))
|
|
7147
|
+
// this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 200)))
|
|
7148
|
+
this.scrollY(Math.max(-5, Math.min(5, delta)))
|
|
7149
|
+
if (this.scrollTimeout) {
|
|
7150
|
+
clearTimeout(this.scrollTimeout)
|
|
7151
|
+
}
|
|
7152
|
+
}
|
|
7153
|
+
}, (1000 / fps) * i)
|
|
7154
|
+
}
|
|
7155
|
+
}
|
|
7031
7156
|
render (data, calcSizes = true) {
|
|
7032
7157
|
if (!this.options.columns) {
|
|
7033
7158
|
console.log(`No columns provided for table with ID ${this.elementId}`)
|
|
@@ -7038,6 +7163,7 @@ class WebsyTable3 {
|
|
|
7038
7163
|
return
|
|
7039
7164
|
}
|
|
7040
7165
|
// this.data = []
|
|
7166
|
+
this.currentData = []
|
|
7041
7167
|
// Adjust the sizing of the header/body/footer
|
|
7042
7168
|
if (calcSizes === true) {
|
|
7043
7169
|
const sample = this.createSample(data)
|