@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
|
@@ -6020,6 +6020,7 @@ class WebsyTable3 {
|
|
|
6020
6020
|
minusIcon: WebsyDesigns.Icons.MinusFilled
|
|
6021
6021
|
}
|
|
6022
6022
|
this.options = Object.assign({}, DEFAULTS, options)
|
|
6023
|
+
this.isTouchDevice = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)
|
|
6023
6024
|
this.sizes = {}
|
|
6024
6025
|
this.currentData = []
|
|
6025
6026
|
this.scrollDragging = false
|
|
@@ -6054,6 +6055,7 @@ class WebsyTable3 {
|
|
|
6054
6055
|
<div id="${this.elementId}_hScrollContainer" class="websy-h-scroll-container">
|
|
6055
6056
|
<div id="${this.elementId}_hScrollHandle" class="websy-scroll-handle websy-scroll-handle-x"></div>
|
|
6056
6057
|
</div>
|
|
6058
|
+
<div id="${this.elementId}_touchScroller" class="websy-table-touch-scroller hidden"></div>
|
|
6057
6059
|
</div>
|
|
6058
6060
|
<div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
|
|
6059
6061
|
<div>
|
|
@@ -6061,7 +6063,7 @@ class WebsyTable3 {
|
|
|
6061
6063
|
<div id="${this.elementId}_errorMessage"></div>
|
|
6062
6064
|
</div>
|
|
6063
6065
|
</div>
|
|
6064
|
-
<div id="${this.elementId}_dropdownContainer"></div>
|
|
6066
|
+
<div id="${this.elementId}_dropdownContainer" class="table-dropdown-container"></div>
|
|
6065
6067
|
<div id="${this.elementId}_loadingContainer"></div>
|
|
6066
6068
|
</div>
|
|
6067
6069
|
`
|
|
@@ -6076,6 +6078,9 @@ class WebsyTable3 {
|
|
|
6076
6078
|
el.innerHTML = html
|
|
6077
6079
|
el.addEventListener('click', this.handleClick.bind(this))
|
|
6078
6080
|
el.addEventListener('mousedown', this.handleMouseDown.bind(this))
|
|
6081
|
+
el.addEventListener('touchstart', this.handleTouchStart.bind(this))
|
|
6082
|
+
window.addEventListener('touchmove', this.handleTouchMove.bind(this))
|
|
6083
|
+
window.addEventListener('touchend', this.handleTouchEnd.bind(this))
|
|
6079
6084
|
window.addEventListener('mousemove', this.handleMouseMove.bind(this))
|
|
6080
6085
|
window.addEventListener('mouseup', this.handleMouseUp.bind(this))
|
|
6081
6086
|
let scrollEl = document.getElementById(`${this.elementId}_tableBody`)
|
|
@@ -6134,7 +6139,8 @@ class WebsyTable3 {
|
|
|
6134
6139
|
data.forEach((row, rowIndex) => {
|
|
6135
6140
|
bodyHtml += `<tr class="websy-table-row">`
|
|
6136
6141
|
row.forEach((cell, cellIndex) => {
|
|
6137
|
-
let sizeIndex = cell.level || cellIndex
|
|
6142
|
+
let sizeIndex = cell.level || cellIndex
|
|
6143
|
+
let colIndex = cell.index || cellIndex
|
|
6138
6144
|
if (typeof sizingColumns[sizeIndex] === 'undefined' || sizingColumns[sizeIndex].show === false) {
|
|
6139
6145
|
return // need to revisit this logic
|
|
6140
6146
|
}
|
|
@@ -6169,7 +6175,7 @@ class WebsyTable3 {
|
|
|
6169
6175
|
rowspan='${cell.rowspan || 1}'
|
|
6170
6176
|
data-row-index='${rowIndex}'
|
|
6171
6177
|
data-cell-index='${cellIndex}'
|
|
6172
|
-
data-col-index='${
|
|
6178
|
+
data-col-index='${colIndex}'
|
|
6173
6179
|
`
|
|
6174
6180
|
// if (useWidths === true) {
|
|
6175
6181
|
// bodyHtml += `
|
|
@@ -6183,7 +6189,7 @@ class WebsyTable3 {
|
|
|
6183
6189
|
class='websy-table-cell-content'
|
|
6184
6190
|
data-row-index='${rowIndex}'
|
|
6185
6191
|
data-cell-index='${cellIndex}'
|
|
6186
|
-
data-col-index='${
|
|
6192
|
+
data-col-index='${colIndex}'
|
|
6187
6193
|
>`
|
|
6188
6194
|
if (cell.expandable === true) {
|
|
6189
6195
|
bodyHtml += `<i
|
|
@@ -6545,6 +6551,9 @@ class WebsyTable3 {
|
|
|
6545
6551
|
}
|
|
6546
6552
|
}
|
|
6547
6553
|
handleMouseDown (event) {
|
|
6554
|
+
if (this.isTouchDevice === true) {
|
|
6555
|
+
return
|
|
6556
|
+
}
|
|
6548
6557
|
if (event.target.classList.contains('websy-scroll-handle-y')) {
|
|
6549
6558
|
// set up the scroll start values
|
|
6550
6559
|
this.scrollDragging = true
|
|
@@ -6592,8 +6601,89 @@ class WebsyTable3 {
|
|
|
6592
6601
|
this.scrollX(Math.max(-5, Math.min(5, event.deltaX)))
|
|
6593
6602
|
}
|
|
6594
6603
|
else {
|
|
6604
|
+
console.log('delta', event.deltaY)
|
|
6595
6605
|
this.scrollY(Math.max(-5, Math.min(5, event.deltaY)))
|
|
6596
6606
|
}
|
|
6607
|
+
}
|
|
6608
|
+
else if (this.options.onNativeScroll) {
|
|
6609
|
+
const el = document.getElementById(`${this.elementId}_tableBody`)
|
|
6610
|
+
this.options.onNativeScroll(el.scrollTop)
|
|
6611
|
+
}
|
|
6612
|
+
}
|
|
6613
|
+
handleTouchEnd (event) {
|
|
6614
|
+
console.log('touch end fired')
|
|
6615
|
+
if (typeof event.targetTouches !== 'undefined') {
|
|
6616
|
+
this.isTouchScrolling = false
|
|
6617
|
+
this.touchEndTime = (new Date()).getTime()
|
|
6618
|
+
this.isPerpetual = true
|
|
6619
|
+
// this.perpetualScroll()
|
|
6620
|
+
this.touchStartTime = null
|
|
6621
|
+
const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
|
|
6622
|
+
touchScrollEl.classList.add('hidden')
|
|
6623
|
+
}
|
|
6624
|
+
}
|
|
6625
|
+
handleTouchMove (event) {
|
|
6626
|
+
console.log(event.target.classList)
|
|
6627
|
+
if (this.isTouchScrolling === true) {
|
|
6628
|
+
event.preventDefault()
|
|
6629
|
+
event.stopPropagation()
|
|
6630
|
+
if (typeof event.targetTouches !== 'undefined' && event.targetTouches.length > 0) {
|
|
6631
|
+
let deltaX = (this.mouseXStart - event.targetTouches[0].pageX)
|
|
6632
|
+
let deltaY = (this.mouseYStart - event.targetTouches[0].pageY)
|
|
6633
|
+
// need to adjust the delta so that it scrolls at a reasonable speed/distance
|
|
6634
|
+
const scrollHandleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
6635
|
+
const scrollHandleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
6636
|
+
// if (Math.abs(deltaY) > this.sizes.cellHeight) {
|
|
6637
|
+
// this.isTouchScrolling = true
|
|
6638
|
+
// }
|
|
6639
|
+
// else {
|
|
6640
|
+
// this.isTouchScrolling = false
|
|
6641
|
+
// }
|
|
6642
|
+
console.log('delta init', deltaY)
|
|
6643
|
+
// deltaX = deltaX * (scrollHandleXEl.offsetWidth / this.sizes.scrollableWidth)
|
|
6644
|
+
// deltaY = deltaY * (scrollHandleYEl.offsetHeight / this.sizes.bodyHeight)
|
|
6645
|
+
// console.log('delta', deltaY)
|
|
6646
|
+
// NW
|
|
6647
|
+
// else if (Math.abs(deltaX) > 50) {
|
|
6648
|
+
// this.isTouchScrolling = false
|
|
6649
|
+
// }
|
|
6650
|
+
this.currentClientY = event.targetTouches[0].pageY
|
|
6651
|
+
this.currentTouchtime = (new Date()).getTime()
|
|
6652
|
+
// end
|
|
6653
|
+
// delta = Math.min(10, delta)
|
|
6654
|
+
// delta = Math.max(-10, delta)
|
|
6655
|
+
if (this.isTouchScrolling === true) {
|
|
6656
|
+
// this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 250)))
|
|
6657
|
+
if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 10) {
|
|
6658
|
+
this.scrollX(Math.max(-5, Math.min(5, deltaX)))
|
|
6659
|
+
}
|
|
6660
|
+
else {
|
|
6661
|
+
this.scrollY(Math.max(-5, Math.min(5, deltaY)))
|
|
6662
|
+
}
|
|
6663
|
+
}
|
|
6664
|
+
}
|
|
6665
|
+
}
|
|
6666
|
+
}
|
|
6667
|
+
handleTouchStart (event) {
|
|
6668
|
+
if (event.target.classList.contains('websy-table-cell-expand')) {
|
|
6669
|
+
return
|
|
6670
|
+
}
|
|
6671
|
+
if (event.target.classList.contains('websy-table-cell-collapse')) {
|
|
6672
|
+
return
|
|
6673
|
+
}
|
|
6674
|
+
console.log(event.target.classList)
|
|
6675
|
+
if (this.options.virtualScroll === true) {
|
|
6676
|
+
this.touchStartTime = (new Date()).getTime()
|
|
6677
|
+
this.isTouchScrolling = true
|
|
6678
|
+
this.isPerpetual = false
|
|
6679
|
+
this.mouseYStart = event.targetTouches[0].pageY
|
|
6680
|
+
this.mouseXStart = event.targetTouches[0].pageX
|
|
6681
|
+
const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
|
|
6682
|
+
touchScrollEl.classList.remove('hidden')
|
|
6683
|
+
const handleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
|
|
6684
|
+
this.handleYStart = handleYEl.offsetTop
|
|
6685
|
+
const handleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
|
|
6686
|
+
this.handleXStart = handleXEl.offsetLeft
|
|
6597
6687
|
}
|
|
6598
6688
|
}
|
|
6599
6689
|
hideError () {
|
|
@@ -6613,6 +6703,41 @@ class WebsyTable3 {
|
|
|
6613
6703
|
hideLoading () {
|
|
6614
6704
|
this.loadingDialog.hide()
|
|
6615
6705
|
}
|
|
6706
|
+
perpetualScroll () {
|
|
6707
|
+
// if the currentTouchtime and touchEndTime are more than 300ms apart then we abort the perpetual scroll
|
|
6708
|
+
if (this.touchEndTime - this.currentTouchtime > 300) {
|
|
6709
|
+
return
|
|
6710
|
+
}
|
|
6711
|
+
// get the difference in time between when the touch initially started and when it ended
|
|
6712
|
+
// the longer the touch duration, the slower the scroll
|
|
6713
|
+
let touchDuration = this.touchEndTime - this.touchStartTime
|
|
6714
|
+
// get the distance moved between when the touch initially started and when it ended
|
|
6715
|
+
let touchDistance = this.currentClientY - this.mouseYStart
|
|
6716
|
+
// the bigger the distance, the more we scroll
|
|
6717
|
+
// use the duration and distance to calculate the duration of the perpetual scroll
|
|
6718
|
+
let perpetualDistance = Math.abs(touchDistance * (1 / (touchDuration / 1000)))
|
|
6719
|
+
let perpetualDuration = touchDuration * 1.5 / 1000
|
|
6720
|
+
let requiredFrames = Math.abs(Math.ceil(perpetualDistance / this.sizes.cellHeight))
|
|
6721
|
+
let fps = requiredFrames / perpetualDuration
|
|
6722
|
+
let direction = touchDistance > 0 ? -1 : 1
|
|
6723
|
+
for (let i = 0; i < requiredFrames; i++) {
|
|
6724
|
+
setTimeout(() => {
|
|
6725
|
+
let delta = (this.mouseYStart - this.currentClientY + (this.sizes.cellHeight * (i + 1)) * direction)
|
|
6726
|
+
delta = Math.min(10, delta)
|
|
6727
|
+
delta = Math.max(-10, delta)
|
|
6728
|
+
// only run this if isPerpetual === true
|
|
6729
|
+
// this value is reset to false on touchStart
|
|
6730
|
+
if (this.isPerpetual === true) {
|
|
6731
|
+
// this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 250)))
|
|
6732
|
+
// this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 200)))
|
|
6733
|
+
this.scrollY(Math.max(-5, Math.min(5, delta)))
|
|
6734
|
+
if (this.scrollTimeout) {
|
|
6735
|
+
clearTimeout(this.scrollTimeout)
|
|
6736
|
+
}
|
|
6737
|
+
}
|
|
6738
|
+
}, (1000 / fps) * i)
|
|
6739
|
+
}
|
|
6740
|
+
}
|
|
6616
6741
|
render (data, calcSizes = true) {
|
|
6617
6742
|
if (!this.options.columns) {
|
|
6618
6743
|
console.log(`No columns provided for table with ID ${this.elementId}`)
|
|
@@ -6623,6 +6748,7 @@ class WebsyTable3 {
|
|
|
6623
6748
|
return
|
|
6624
6749
|
}
|
|
6625
6750
|
// this.data = []
|
|
6751
|
+
this.currentData = []
|
|
6626
6752
|
// Adjust the sizing of the header/body/footer
|
|
6627
6753
|
if (calcSizes === true) {
|
|
6628
6754
|
const sample = this.createSample(data)
|