Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions src/lib/scroll/ScrollElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ class ScrollElement extends Component {
}
}

/**
* needed to handle scrolling with trackpad
*/
handleScroll = () => {
const scrollX = this.scrollComponent.scrollLeft
this.props.onScroll(scrollX)
}

refHandler = el => {
this.scrollComponent = el
this.props.scrollRef(el)
Expand All @@ -40,13 +32,10 @@ class ScrollElement extends Component {


handleWheel = e => {
const { traditionalZoom } = this.props


e.preventDefault()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is preventing the horizontal scroll from working. I think this can be fixed with

handleWheel = e => {
    const isHorizontalScrolling = e.wheelDeltaY === 0

    // zoom in the time dimension
    if (e.ctrlKey || e.metaKey || e.altKey) {
      e.preventDefault()
      const parentPosition = getParentPosition(e.currentTarget)
      const xPosition = e.clientX - parentPosition.x

      const speed = e.ctrlKey ? 10 : e.metaKey ? 3 : 1

      // convert vertical zoom to horiziontal
      this.props.onWheelZoom(speed, xPosition, e.deltaY)
    } else if (e.shiftKey) {
      e.preventDefault()
      // shift+scroll event from a touchpad has deltaY property populated; shift+scroll event from a mouse has deltaX
      this.props.onScroll(this.scrollComponent.scrollLeft + (e.deltaY || e.deltaX))
      // no modifier pressed? we prevented the default event, so scroll or zoom as needed
    } else if (isHorizontalScrolling) {
      e.preventDefault()
      this.props.onScroll(this.scrollComponent.scrollLeft + e.deltaX) 
      }
    }

  }

Also, this will cause performance issues, so you should consider adding window.requestAnimationFrame when calling this.props.onScroll(...)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @DarioG, please check the pr: #834

fixed this issue it was related to the another method


// zoom in the time dimension
if (e.ctrlKey || e.metaKey || e.altKey) {
e.preventDefault()
const parentPosition = getParentPosition(e.currentTarget)
const xPosition = e.clientX - parentPosition.x

Expand All @@ -55,10 +44,11 @@ class ScrollElement extends Component {
// convert vertical zoom to horiziontal
this.props.onWheelZoom(speed, xPosition, e.deltaY)
} else if (e.shiftKey) {
e.preventDefault()
// shift+scroll event from a touchpad has deltaY property populated; shift+scroll event from a mouse has deltaX
this.props.onScroll(this.scrollComponent.scrollLeft + (e.deltaY || e.deltaX))
// no modifier pressed? we prevented the default event, so scroll or zoom as needed
} else {
this.props.onScroll(this.scrollComponent.scrollLeft + e.deltaX)
}
}

Expand Down Expand Up @@ -198,7 +188,6 @@ class ScrollElement extends Component {
onTouchStart={this.handleTouchStart}
onTouchMove={this.handleTouchMove}
onTouchEnd={this.handleTouchEnd}
onScroll={this.handleScroll}
>
{children}
</div>
Expand Down