Skip to main content

Input Type

The inputType option sets the input device types to enable as an array. You can allow or restrict specific input devices.

import Flicking from "@egjs/flicking";
import "@egjs/flicking/dist/flicking.css";
import "./styles.css";

// inputType: ["touch", "mouse"] (default)
new Flicking("#flick-both", {
  inputType: ["touch", "mouse"],
  align: "center"
});

// inputType: ["touch"]
new Flicking("#flick-touch", {
  inputType: ["touch"],
  align: "center"
});

// inputType: ["mouse"]
new Flicking("#flick-mouse", {
  inputType: ["mouse"],
  align: "center"
});

Summary

Key Options

OptionTypeDefaultDescription
inputTypestring[]["touch", "mouse"]Input device types to enable

Comparison by Value

ValueBehaviorSuitable For
["touch", "mouse"]Both touch and mouse allowed (default)General usage, cross-platform
["touch"]Touch only, mouse drag ignoredTouch-only UI, preventing mouse drag
["mouse"]Mouse only, touch ignoredDesktop-only UI

Details

How inputType Works

Only the input types included in the array are used for Flicking interaction. Input types not included are ignored.

// Allow all input (default)
inputType: ["touch", "mouse"]

// Touch only
inputType: ["touch"]

// Mouse only
inputType: ["mouse"]

// Disable all input
inputType: []

Supported Input Types

  • "touch": Touchscreen input (smartphones, tablets)
  • "mouse": Mouse drag input (desktop)

iOSEdgeSwipeThreshold

In iOS Safari, swiping from the edge of the screen triggers the browser's back/forward navigation gesture. The iOSEdgeSwipeThreshold option specifies the width (px) of this area, so touches starting within that range are passed to the browser instead of being handled by Flicking.

const flicking = new Flicking("#el", {
inputType: ["touch", "mouse"],
iOSEdgeSwipeThreshold: 30 // Default: 30px area on each side is deferred to browser gestures
});
Only applies on iOS

iOSEdgeSwipeThreshold only works on iOS devices. The default value (30px) is generally sufficient. For full-screen horizontal sliders where edge panels are frequently dragged, you can reduce the value or set it to 0.

  • Relationship with disableOnInit: disableOnInit: true disables all input, and inputType: [] has the same effect. The difference is that disableOnInit can be later activated with enable().

Use Cases

When to use?
  • ["touch", "mouse"]: General web apps, supporting various devices
  • ["touch"]: Mobile-only UI, when you want only button/arrow control on desktop
  • ["mouse"]: Desktop-only apps, when touch input is used for other purposes

Notes

Provide alternatives when restricting input

Restricting certain input types means users on those devices cannot interact. Provide alternatives such as navigation buttons or keyboard controls.

Accessibility considerations

Generally, using the default ["touch", "mouse"] is recommended from an accessibility standpoint. Do not restrict input types without a specific reason.