LVRS Document Viewer
components/control/WheelScrollGuard.svx
Path: components/control/WheelScrollGuard.svx
WheelScrollGuard
Location: qml/components/control/util/WheelScrollGuard.qml
WheelScrollGuard routes wheel deltas to an intended inner flickable and optionally consumes the event.
Purpose
- Prevent nested scroll bleed between inner and outer scroll surfaces.
- Convert wheel delta input into bounded
contentYupdates.
API
targetFlickable(must exposecontentY,contentHeight,height)consumeInside(defaulttrue)fallbackStep(defaultTheme.gap20)wheelRouted(wheelEvent, delta, previousContentY, nextContentY)signal
Usage
import LVRS 1.0 as LV
LV.WheelScrollGuard {
anchors.fill: parent
targetFlickable: innerFlick
consumeInside: true
}
How It Works
- Uses internal
EventListenertriggerwheel. - Routes events only when pointer point lies within target flickable bounds.
- Delta source priority:
pixelDelta.y->angleDelta.yconverted byfallbackStep. - Applies bounded
contentYupdates (0..maxContentY) and emitswheelRouted.
Advanced Example: Passive Routing Mode
import LVRS 1.0 as LV
LV.WheelScrollGuard {
targetFlickable: editorFlick
consumeInside: false
}
This mode routes wheel delta but does not force event acceptance.
FAQ
Q. Why does wheel scroll still affect outer container?
A. Check consumeInside. When false, event propagation is intentionally allowed.
Q. Why no movement even though wheel events fire?
A. Verify target exposes valid contentHeight, height, and currently has scrollable overflow.
Validation Checklist
- pointer-inside detection maps correctly under nested transforms,
- delta conversion behaves consistently across mouse and touchpad,
- bounded scrolling prevents overshoot past content limits.