@websy/websy-designs 1.7.19 → 1.8.0

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.
@@ -1471,8 +1471,8 @@ class WebsyDragDrop {
1471
1471
  el.innerHTML = html
1472
1472
  this.options.items.forEach((item, i) => {
1473
1473
  if (item.component) {
1474
- if (item.isQlikPlugin && WebsyDesigns.QlikPlugin[item.component]) {
1475
- item.instance = new WebsyDesigns.QlikPlugin[item.component](`${item.id}_component`, item.options)
1474
+ if (item.isQlikPlugin && WebsyDesigns.QlikPlugins[item.component]) {
1475
+ item.instance = new WebsyDesigns.QlikPlugins[item.component](`${item.id}_component`, item.options)
1476
1476
  }
1477
1477
  else if (WebsyDesigns[item.component]) {
1478
1478
  item.instance = new WebsyDesigns[item.component](`${item.id}_component`, item.options)
@@ -4650,11 +4650,21 @@ class Switch {
4650
4650
  }
4651
4651
  disable () {
4652
4652
  this.options.enabled = false
4653
- this.render()
4653
+ let method = this.options.enabled === true ? 'add' : 'remove'
4654
+ const el = document.getElementById(`${this.elementId}_switch`)
4655
+ el.classList[method]('enabled')
4656
+ if (this.options.onToggle) {
4657
+ this.options.onToggle(this.options.enabled)
4658
+ }
4654
4659
  }
4655
4660
  enable () {
4656
4661
  this.options.enabled = true
4657
- this.render()
4662
+ let method = this.options.enabled === true ? 'add' : 'remove'
4663
+ const el = document.getElementById(`${this.elementId}_switch`)
4664
+ el.classList[method]('enabled')
4665
+ if (this.options.onToggle) {
4666
+ this.options.onToggle(this.options.enabled)
4667
+ }
4658
4668
  }
4659
4669
  handleClick (event) {
4660
4670
  this.options.enabled = !this.options.enabled
@@ -6041,7 +6051,7 @@ class WebsyTable3 {
6041
6051
  const el = document.getElementById(this.elementId)
6042
6052
  if (el) {
6043
6053
  let html = `
6044
- <div id='${this.elementId}_tableContainer' class='websy-vis-table-3 ${this.options.paging === 'pages' ? 'with-paging' : ''} ${this.options.virtualScroll === true ? 'with-virtual-scroll' : ''}'>
6054
+ <div id='${this.elementId}_tableContainer' class='websy-vis-table-3 ${this.options.paging === 'pages' ? 'with-paging' : ''} ${this.options.virtualScroll === true ? 'with-virtual-scroll' : ''} ${this.isTouchDevice === true && this.options.virtualScroll === true ? 'touch-device' : ''}'>
6045
6055
  <!--<div class="download-button">
6046
6056
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M16 11h5l-9 10-9-10h5v-11h8v11zm1 11h-10v2h10v-2z"/></svg>
6047
6057
  </div>-->
@@ -6471,8 +6481,8 @@ class WebsyTable3 {
6471
6481
  }
6472
6482
  this.sizes.rowsToRender = Math.ceil(this.sizes.bodyHeight / this.sizes.cellHeight)
6473
6483
  this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight
6474
- this.startRow = 0
6475
- this.endRow = this.sizes.rowsToRender
6484
+ // this.startRow = 0
6485
+ this.endRow = this.startRow + this.sizes.rowsToRender
6476
6486
  this.startCol = 0
6477
6487
  this.endCol = this.options.columns[this.options.columns.length - 1].length
6478
6488
  if (this.sizes.rowsToRender < this.totalRowCount) {
@@ -6561,11 +6571,11 @@ class WebsyTable3 {
6561
6571
  }
6562
6572
  }
6563
6573
  }
6564
- handleMouseDown (event) {
6565
- if (this.isTouchDevice === true) {
6574
+ handleMouseDown (event) {
6575
+ if (this.isTouchDevice) {
6566
6576
  return
6567
6577
  }
6568
- if (event.target.classList.contains('websy-scroll-handle-y')) {
6578
+ if (event.target.classList.contains('websy-scroll-handle-y')) {
6569
6579
  // set up the scroll start values
6570
6580
  this.scrollDragging = true
6571
6581
  this.scrollDirection = 'y'
@@ -6576,6 +6586,9 @@ class WebsyTable3 {
6576
6586
  // console.log(scrollHandleEl.offsetTop)
6577
6587
  }
6578
6588
  else if (event.target.classList.contains('websy-scroll-handle-x')) {
6589
+ if (this.isTouchDevice) {
6590
+ event.preventDefault()
6591
+ }
6579
6592
  this.scrollDragging = true
6580
6593
  this.scrollDirection = 'x'
6581
6594
  const scrollHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
@@ -6583,9 +6596,12 @@ class WebsyTable3 {
6583
6596
  this.mouseXStart = event.pageX
6584
6597
  }
6585
6598
  }
6586
- handleMouseMove (event) {
6599
+ handleMouseMove (event) {
6587
6600
  // event.preventDefault()
6588
6601
  if (this.scrollDragging === true) {
6602
+ if (this.isTouchDevice) {
6603
+ event.preventDefault()
6604
+ }
6589
6605
  if (this.scrollDirection === 'y') {
6590
6606
  const diff = event.pageY - this.mouseYStart
6591
6607
  this.scrollY(diff)
@@ -6645,12 +6661,18 @@ class WebsyTable3 {
6645
6661
  }
6646
6662
  handleTouchEnd (event) {
6647
6663
  // console.log('touch end fired')
6664
+ this.scrollDragging = false
6665
+ this.cellDragging = false
6666
+ this.handleYStart = null
6667
+ this.mouseYStart = null
6668
+ this.handleXStart = null
6669
+ this.mouseXStart = null
6648
6670
  if (typeof event.targetTouches !== 'undefined') {
6649
6671
  this.isTouchScrolling = false
6650
- this.touchEndTime = (new Date()).getTime()
6651
- this.isPerpetual = true
6672
+ // this.touchEndTime = (new Date()).getTime()
6673
+ // this.isPerpetual = true
6652
6674
  // this.perpetualScroll()
6653
- this.touchStartTime = null
6675
+ // this.touchStartTime = null
6654
6676
  // const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
6655
6677
  // touchScrollEl.classList.add('hidden')
6656
6678
  }
@@ -6661,47 +6683,68 @@ class WebsyTable3 {
6661
6683
  event.preventDefault()
6662
6684
  event.stopPropagation()
6663
6685
  if (typeof event.targetTouches !== 'undefined' && event.targetTouches.length > 0) {
6664
- let deltaX = (this.mouseXStart - event.targetTouches[0].pageX)
6665
- let deltaY = (this.mouseYStart - event.targetTouches[0].pageY)
6666
- const hScrollContainerEl = document.getElementById(`${this.elementId}_hScrollContainer`)
6667
- const vScrollContainerEl = document.getElementById(`${this.elementId}_vScrollContainer`)
6668
- const hScrollHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
6669
- const vScrollHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
6670
- let translatedDeltaX = deltaX * (hScrollHandleEl.getBoundingClientRect().width / vScrollContainerEl.getBoundingClientRect().width)
6671
- let translatedDeltaY = deltaY * (vScrollHandleEl.getBoundingClientRect().height / vScrollContainerEl.getBoundingClientRect().height)
6672
- // need to adjust the delta so that it scrolls at a reasonable speed/distance
6673
- const scrollHandleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
6674
- const scrollHandleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
6675
- // if (Math.abs(deltaY) > this.sizes.cellHeight) {
6676
- // this.isTouchScrolling = true
6677
- // }
6678
- // else {
6679
- // this.isTouchScrolling = false
6680
- // }
6681
- // console.log('delta', this.mouseYStart, event.targetTouches[0].pageY, deltaY)
6682
- // deltaX = deltaX * (scrollHandleXEl.offsetWidth / this.sizes.scrollableWidth)
6683
- // deltaY = deltaY * (scrollHandleYEl.offsetHeight / this.sizes.bodyHeight)
6684
- // console.log('delta', deltaY)
6685
- // NW
6686
- // else if (Math.abs(deltaX) > 50) {
6687
- // this.isTouchScrolling = false
6688
- // }
6689
- this.currentClientY = event.targetTouches[0].pageY
6690
- this.currentTouchtime = (new Date()).getTime()
6691
- // end
6692
- // delta = Math.min(10, delta)
6693
- // delta = Math.max(-10, delta)
6694
- if (this.isTouchScrolling === true) {
6695
- // this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 250)))
6696
- if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 20) {
6697
- // this.scrollX(Math.max(-5, Math.min(5, translatedDeltaX)))
6698
- this.scrollX(translatedDeltaX)
6699
- }
6700
- else if (deltaY > 20) {
6701
- // this.scrollY(Math.max(-5, Math.min(5, translatedDeltaY)))
6702
- this.scrollY(translatedDeltaY)
6703
- }
6704
- }
6686
+ event.deltaX = this.touchXStart - event.targetTouches[0].pageX
6687
+ event.deltaY = this.touchYStart - event.targetTouches[0].pageY
6688
+ if (Math.abs(event.deltaY) > 50) {
6689
+ event.deltaX = 0
6690
+ this.handleScrollWheel(event)
6691
+ }
6692
+ else if (Math.abs(event.deltaX) > 50) {
6693
+ event.deltaY = 0
6694
+ this.handleScrollWheel(event)
6695
+ }
6696
+ // let deltaX = (this.mouseXStart - event.targetTouches[0].pageX)
6697
+ // let deltaY = (this.mouseYStart - event.targetTouches[0].pageY)
6698
+ // const hScrollContainerEl = document.getElementById(`${this.elementId}_hScrollContainer`)
6699
+ // const vScrollContainerEl = document.getElementById(`${this.elementId}_vScrollContainer`)
6700
+ // const hScrollHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
6701
+ // const vScrollHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
6702
+ // let translatedDeltaX = deltaX * (hScrollHandleEl.getBoundingClientRect().width / vScrollContainerEl.getBoundingClientRect().width)
6703
+ // let translatedDeltaY = deltaY * (vScrollHandleEl.getBoundingClientRect().height / vScrollContainerEl.getBoundingClientRect().height)
6704
+ // // need to adjust the delta so that it scrolls at a reasonable speed/distance
6705
+ // const scrollHandleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
6706
+ // const scrollHandleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
6707
+ // // if (Math.abs(deltaY) > this.sizes.cellHeight) {
6708
+ // // this.isTouchScrolling = true
6709
+ // // }
6710
+ // // else {
6711
+ // // this.isTouchScrolling = false
6712
+ // // }
6713
+ // // console.log('delta', this.mouseYStart, event.targetTouches[0].pageY, deltaY)
6714
+ // // deltaX = deltaX * (scrollHandleXEl.offsetWidth / this.sizes.scrollableWidth)
6715
+ // // deltaY = deltaY * (scrollHandleYEl.offsetHeight / this.sizes.bodyHeight)
6716
+ // // console.log('delta', deltaY)
6717
+ // // NW
6718
+ // // else if (Math.abs(deltaX) > 50) {
6719
+ // // this.isTouchScrolling = false
6720
+ // // }
6721
+ // this.currentClientY = event.targetTouches[0].pageY
6722
+ // this.currentTouchtime = (new Date()).getTime()
6723
+ // // end
6724
+ // // delta = Math.min(10, delta)
6725
+ // // delta = Math.max(-10, delta)
6726
+ // if (this.isTouchScrolling === true) {
6727
+ // // this.$scope.scrollTop += (delta / (this.$scope.layout.qHyperCube.qSize.qcy / this.$scope.rowsToLoad / (this.$scope.totalSpaceAvailable / 250)))
6728
+ // if (Math.abs(deltaX) > Math.abs(deltaY) && deltaX > 20) {
6729
+ // // this.scrollX(Math.max(-5, Math.min(5, translatedDeltaX)))
6730
+ // this.scrollX(translatedDeltaX)
6731
+ // }
6732
+ // else if (deltaY > 20) {
6733
+ // // this.scrollY(Math.max(-5, Math.min(5, translatedDeltaY)))
6734
+ // this.scrollY(translatedDeltaY)
6735
+ // }
6736
+ // }
6737
+ }
6738
+ }
6739
+ if (this.scrollDragging === true) {
6740
+ event.preventDefault()
6741
+ if (this.scrollDirection === 'y') {
6742
+ const diff = event.targetTouches[0].pageY - this.mouseYStart
6743
+ this.scrollY(diff)
6744
+ }
6745
+ else if (this.scrollDirection === 'x') {
6746
+ const diff = event.targetTouches[0].pageX - this.mouseXStart
6747
+ this.scrollX(diff)
6705
6748
  }
6706
6749
  }
6707
6750
  }
@@ -6713,19 +6756,42 @@ class WebsyTable3 {
6713
6756
  return
6714
6757
  }
6715
6758
  // console.log(event.target.classList)
6716
- if (this.options.virtualScroll === true) {
6717
- this.touchStartTime = (new Date()).getTime()
6718
- this.isTouchScrolling = true
6719
- this.isPerpetual = false
6759
+ if (event.target.classList.contains('websy-table-touch-scroller')) {
6760
+ if (this.options.virtualScroll === true) {
6761
+ // this.touchStartTime = (new Date()).getTime()
6762
+ this.isTouchScrolling = true
6763
+ // this.isPerpetual = false
6764
+ this.touchYStart = event.targetTouches[0].pageY
6765
+ this.touchXStart = event.targetTouches[0].pageX
6766
+ }
6767
+ }
6768
+ if (event.target.classList.contains('websy-scroll-handle-y')) {
6769
+ // set up the scroll start values
6770
+ this.scrollDragging = true
6771
+ this.scrollDirection = 'y'
6772
+ const scrollHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
6773
+ this.handleYStart = scrollHandleEl.offsetTop
6720
6774
  this.mouseYStart = event.targetTouches[0].pageY
6721
- this.mouseXStart = event.targetTouches[0].pageX
6722
- // const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
6723
- // touchScrollEl.classList.remove('hidden')
6724
- const handleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
6725
- this.handleYStart = handleYEl.offsetTop
6726
- const handleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
6727
- this.handleXStart = handleXEl.offsetLeft
6728
- }
6775
+ // console.log('mouse down', this.handleYStart, this.mouseYStart)
6776
+ // console.log(scrollHandleEl.offsetTop)
6777
+ }
6778
+ else if (event.target.classList.contains('websy-scroll-handle-x')) {
6779
+ if (this.isTouchDevice) {
6780
+ event.preventDefault()
6781
+ }
6782
+ this.scrollDragging = true
6783
+ this.scrollDirection = 'x'
6784
+ const scrollHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
6785
+ this.handleXStart = scrollHandleEl.offsetLeft
6786
+ this.mouseXStart = event.targetTouches[0].pageX
6787
+ }
6788
+ // // const touchScrollEl = document.getElementById(`${this.elementId}_touchScroller`)
6789
+ // // touchScrollEl.classList.remove('hidden')
6790
+ // const handleYEl = document.getElementById(`${this.elementId}_vScrollHandle`)
6791
+ // this.handleYStart = handleYEl.offsetTop
6792
+ // const handleXEl = document.getElementById(`${this.elementId}_hScrollHandle`)
6793
+ // this.handleXStart = handleXEl.offsetLeft
6794
+ // }
6729
6795
  }
6730
6796
  hideError () {
6731
6797
  const el = document.getElementById(`${this.elementId}_tableContainer`)
@@ -6826,6 +6892,10 @@ class WebsyTable3 {
6826
6892
  vScrollEl.style.top = `${this.sizes.header.height + this.sizes.total.height}px`
6827
6893
  vScrollEl.style.height = `${this.sizes.bodyHeight}px`
6828
6894
  vHandleEl.style.height = Math.max(this.options.minHandleSize, this.sizes.bodyHeight * (this.sizes.rowsToRenderPrecise / this.totalRowCount)) + 'px'
6895
+ if (this.startRow !== 0) {
6896
+ const scrollableSpace = vScrollEl.getBoundingClientRect().height - vHandleEl.getBoundingClientRect().height
6897
+ vHandleEl.style.top = Math.round(this.startRow / (this.totalRowCount - this.sizes.rowsToRender) * (scrollableSpace)) + 'px'
6898
+ }
6829
6899
  }
6830
6900
  else {
6831
6901
  vHandleEl.style.height = '0px'
@@ -6834,7 +6904,7 @@ class WebsyTable3 {
6834
6904
  let hHandleEl = document.getElementById(`${this.elementId}_hScrollHandle`)
6835
6905
  if (this.hScrollRequired === true) {
6836
6906
  hScrollEl.style.left = `${this.sizes.table.width - this.sizes.scrollableWidth}px`
6837
- hScrollEl.style.width = `${this.sizes.scrollableWidth - 20}px`
6907
+ hScrollEl.style.width = `${this.sizes.scrollableWidth - (this.isTouchDevice ? 30 : 20)}px`
6838
6908
  hHandleEl.style.width = Math.max(this.options.minHandleSize, this.sizes.scrollableWidth * (this.sizes.scrollableWidth / this.sizes.totalNonPinnedWidth)) + 'px'
6839
6909
  }
6840
6910
  else {
@@ -6982,7 +7052,7 @@ class WebsyTable3 {
6982
7052
  if (this.endRow === this.totalRowCount) {
6983
7053
  this.startRow += 1
6984
7054
  }
6985
- this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns)
7055
+ this.options.onScroll('y', this.startRow, this.endRow, Math.max(0, this.startCol - this.pinnedColumns), this.endCol - this.pinnedColumns)
6986
7056
  }
6987
7057
  }
6988
7058
  showLoading (options) {
@@ -8672,7 +8742,12 @@ if (!this.brushBarsInitialized[series.key]) {
8672
8742
  }
8673
8743
  removebar (key) {
8674
8744
  /* global key d3 */
8675
- let bars = this.barLayer.selectAll(`.bar_${key}`)
8745
+ this.barLayer.selectAll(`.bar_${key}`)
8746
+ .transition(this.transition)
8747
+ .style('fill-opacity', 1e-6)
8748
+ .remove()
8749
+ // remove from the brush as well
8750
+ this.brushArea.selectAll(`.bar_${key}`)
8676
8751
  .transition(this.transition)
8677
8752
  .style('fill-opacity', 1e-6)
8678
8753
  .remove()