mirror of
https://github.com/storytold/egui.git
synced 2026-11-21 01:52:58 +01:00
* Follows #8665 * Follows #8662 Content can now be pulled past the edge of a `ScrollArea` with increasing resistance, and springs back when released, like iOS/macOS. A flick that coasts into the edge bounces too. **Input paths** * **Drag-to-scroll** (touch): rubber-bands on drag, bounces on kinetic coast. * **Trackpad, fingers down**: rubber-bands mid-gesture, holds while fingers rest, springs back on lift. * **Trackpad, OS momentum phase** (macOS): bounces once off the edge, then the rest of the momentum is ignored. Momentum arriving while already past the edge is ignored, so it doesn't overshoot. * **Mouse wheel / web** (no phases): still hard-clamps, like macOS. * Scroll bars and `scroll_to_*` unchanged. **Scroll chaining** is preserved: an inner scroll area already at its edge when a trackpad gesture starts passes the delta to an enclosing scroll area. The outermost area rubber-bands at its edge. **Structure**: `scroll_physics.rs` holds the maths (iOS resistance curve, exact critically damped spring, exact kinetic decay) and the per-axis rules (`drag`, `step`, `wheel`) as a 1D stateless `AxisPhysics`, with unit tests. `scroll_area.rs` keeps only the glue: build the per-axis physics, call one method per input path, remember which axes to leave unclamped this frame. **API** * `State::offset` is now private, since it may be outside the valid range while rubber-banding. Read it via `State::clamped_offset()` (what the old field used to be) or `State::unclamped_offset()` (where the content is drawn), plus `State::overscroll()`. A deprecated `State::offset()` returns the clamped one. `State::velocity()` is now in offset space (positive = scrolling down/right). * `KineticScrollStyle::rubber_band: bool` to turn it off. Slope (0.55) and spring time (0.1 s) are constants. **Tests**: 8 unit tests on the physics and rules (resistance curve, spring, coast distance, frame-rate independence, chaining, momentum bounce-once and no-overshoot), plus one kittest test wiring a touch drag through `ScrollArea`. * [x] I have followed the instructions in the PR template 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Test apps
Some application to tests various parts of egui and eframe.
At some point it would be nice to have automatic screenshot regression tests for these.