pub struct Engine {
pub scroll_body: ScrollBody,
pub scroll_target: ScrollTarget,
pub index_current: usize,
pub index_previous: usize,
pub scroll_bounds: ScrollBounds,
/* private fields */
}Expand description
Minimal Embla-style engine state for headless parity work.
This is intentionally not a full port of Engine.ts. It is a small, composable core that
supports:
- scroll target selection (
ScrollTarget) - scroll integration (
ScrollBody) - drag release shaping (
DragHandler.upmath) - select event emission (index changes)
Upstream references:
repo-ref/embla-carousel/packages/embla-carousel/src/components/Engine.tsrepo-ref/embla-carousel/packages/embla-carousel/src/components/ScrollTo.tsrepo-ref/embla-carousel/packages/embla-carousel/src/components/ScrollAnimator.ts
Fields§
§scroll_body: ScrollBody§scroll_target: ScrollTarget§index_current: usize§index_previous: usize§scroll_bounds: ScrollBoundsImplementations§
Source§impl Engine
impl Engine
pub fn new( scroll_snaps: Vec<f32>, content_size: f32, config: EngineConfig, ) -> Engine
pub fn set_options( &mut self, loop_enabled: bool, drag_free: bool, skip_snaps: bool, duration: f32, )
pub fn loop_enabled(&self) -> bool
pub fn reinit( &mut self, scroll_snaps: Vec<f32>, content_size: f32, view_size: f32, ) -> Option<SelectEvent>
pub fn constrain_bounds(&mut self, pointer_down: bool)
Sourcepub fn normalize_loop_entities(&mut self)
pub fn normalize_loop_entities(&mut self)
Keeps loop-enabled motion values within the scroll limit by applying Embla-style loop distances.
Unlike ScrollBounds, this is only active for loop=true and does not clamp; it wraps the
location/target by the loop length while keeping integrator velocity intact.
pub fn scroll_to_distance( &mut self, distance: f32, snap_to_closest: bool, ) -> Option<SelectEvent>
pub fn scroll_to_index( &mut self, index: usize, direction: i8, ) -> Option<SelectEvent>
pub fn scroll_to_next(&mut self) -> Option<SelectEvent>
pub fn scroll_to_prev(&mut self) -> Option<SelectEvent>
Sourcepub fn on_drag_release(
&mut self,
pointer_kind: PointerKind,
pointer_delta: f32,
direction: impl Fn(f32) -> f32,
) -> (DragReleaseResult, Option<SelectEvent>)
pub fn on_drag_release( &mut self, pointer_kind: PointerKind, pointer_delta: f32, direction: impl Fn(f32) -> f32, ) -> (DragReleaseResult, Option<SelectEvent>)
Apply Embla-style drag release shaping and scroll to the resulting target.
pointer_delta is the Embla-style flick force in the main axis (px/ms).
direction is the axis direction function (Embla axis.direction).
Trait Implementations§
impl StructuralPartialEq for Engine
Auto Trait Implementations§
impl Freeze for Engine
impl RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl UnwindSafe for Engine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more