Skip to main content

Engine

Struct Engine 

Source
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.up math)
  • select event emission (index changes)

Upstream references:

  • repo-ref/embla-carousel/packages/embla-carousel/src/components/Engine.ts
  • repo-ref/embla-carousel/packages/embla-carousel/src/components/ScrollTo.ts
  • repo-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: ScrollBounds

Implementations§

Source§

impl Engine

Source

pub fn new( scroll_snaps: Vec<f32>, content_size: f32, config: EngineConfig, ) -> Engine

Source

pub fn set_options( &mut self, loop_enabled: bool, drag_free: bool, skip_snaps: bool, duration: f32, )

Source

pub fn loop_enabled(&self) -> bool

Source

pub fn reinit( &mut self, scroll_snaps: Vec<f32>, content_size: f32, view_size: f32, ) -> Option<SelectEvent>

Source

pub fn constrain_bounds(&mut self, pointer_down: bool)

Source

pub fn tick(&mut self, pointer_down: bool)

One engine step (typically one rendered frame).

Source

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.

Source

pub fn scroll_to_distance( &mut self, distance: f32, snap_to_closest: bool, ) -> Option<SelectEvent>

Source

pub fn scroll_to_index( &mut self, index: usize, direction: i8, ) -> Option<SelectEvent>

Source

pub fn scroll_to_next(&mut self) -> Option<SelectEvent>

Source

pub fn scroll_to_prev(&mut self) -> Option<SelectEvent>

Source

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§

Source§

impl Clone for Engine

Source§

fn clone(&self) -> Engine

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Engine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Engine

Source§

fn eq(&self, other: &Engine) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Engine

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UiElementA11yExt for T

Source§

fn a11y(self, decoration: SemanticsDecoration) -> UiElementWithA11y<Self>

Source§

fn a11y_role(self, role: SemanticsRole) -> UiElementWithA11y<Self>

Source§

fn a11y_label(self, label: impl Into<Arc<str>>) -> UiElementWithA11y<Self>

Source§

fn a11y_value(self, value: impl Into<Arc<str>>) -> UiElementWithA11y<Self>

Source§

fn a11y_disabled(self, disabled: bool) -> UiElementWithA11y<Self>

Source§

fn a11y_selected(self, selected: bool) -> UiElementWithA11y<Self>

Source§

fn a11y_expanded(self, expanded: bool) -> UiElementWithA11y<Self>

Source§

fn a11y_checked(self, checked: Option<bool>) -> UiElementWithA11y<Self>

Source§

impl<T> UiElementKeyContextExt for T

Source§

fn key_context( self, key_context: impl Into<Arc<str>>, ) -> UiElementWithKeyContext<Self>

Source§

impl<T> UiElementTestIdExt for T

Source§

fn test_id(self, id: impl Into<Arc<str>>) -> UiElementWithTestId<Self>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more