Skip to content

onLongPress | Allow function as value in delay #4978

@josuelrocha

Description

@josuelrocha

Clear and concise description of the problem

Difficulty in setting a delay value for different pointers.

Suggested solution

export interface OnLongPressOptions {
  // ...
  delay?: number | (event: PointerEvent) => number;
  // ...
}
const onLongPressOptions = {
  // ...
  delay: (event: PointerEvent) => event.pointerType === 'mouse' ? 0 : 500;
  // ...
};

Alternative

No response

Additional context

I know there's a way to determine if it was a long press in the onMouseUp event, but there are things we want to execute on pointerdown. For example, I'm working on a drag and drop feature, so on pointerdown, I want to activate drag immediately on desktop, but on mobile, I want to activate it by holding down the touch for 500ms.

Validations

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions