public void Scroll(int dx, int dy, uint x, uint y, ScrollState state) { _cumulativeDy += dy; if (_cumulativeDy > 0) { // scroll up FloatingButtonVisibility = true; } else if (_cumulativeDy < 0) { // scroll down FloatingButtonVisibility = false; } if (state == ScrollState.End) { _cumulativeDy = 0; } var offset = _toolbarOffset - dy; offset = Math.Max(0, offset); offset = Math.Min(ToolbarHeight, offset); dy -= ToolbarOffset - offset; ToolbarOffset = offset; _servo.Scroll(dx, dy, x, y, state); }