Skip to content

Commit

Permalink
Merge pull request xi-editor#469 from nangtrongvuon/fix-scroll-extern…
Browse files Browse the repository at this point in the history
…al-mouse

Fix janky scrolling on external mice
  • Loading branch information
nangtrongvuon authored Jun 24, 2019
2 parents e6070e3 + c35775a commit ee4383a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/XiEditor/XiClipView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ protocol ScrollInterested: class {
class XiClipView: NSClipView {
weak var delegate: ScrollInterested?

// Smooth scrolling (like the MacBook trackpad or Apple Magic Mouse) sends scroll events that are chunked, continuous and cumulative,
// and thus the scroll view's clipView's bounds is set properly (in small increments) for each of these small chunks of scrolling.
// Scrolling with notched mice scrolls in discrete units, takes into account acceleration but does not redraw the view when the view is continuously redrawn (like in xi-mac) during scrolling.
// This is because the bounds origin is only set after the scrolling has stopped completely.
// We bypass this by simply setting the bound origin immediately.
override func scroll(to newOrigin: NSPoint) {
delegate?.willScroll(to: newOrigin)
super.scroll(to: newOrigin)
super.setBoundsOrigin(newOrigin)
}
}

0 comments on commit ee4383a

Please sign in to comment.