본문으로 건너뛰기

CrossFlicking

CrossFlicking supports flicking that can move in both horizontal and vertical directions.

You can easily create UIs with panels with multiple categories, like the example below.

Spring Wallpaper 1
Cherry blossoms, Bird, Flowers
12345

An example of using CrossFlicking is shown in the demo above.

정보

Moving the first panel up in the vertical Flicking changes to the previous category and changes the index in the horizontal Flicking.

Moving the last panel down in the vertical Flicking changes to the next category and changes the index in the horizontal Flicking.

How to use

<div id="flicking" class="flicking-viewport">
<div class="flicking-camera">
<div>
<div class="flicking-panel">
Panel 1-A
</div>
<div class="flicking-panel">
Panel 1-B
</div>
</div>
<div>
<div class="flicking-panel">
Panel 2-A
</div>
<div class="flicking-panel">
Panel 2-B
</div>
</div>
<div>
<div class="flicking-panel">
Panel 3-A
</div>
<div class="flicking-panel">
Panel 3-B
</div>
</div>
</div>
</div>

<script>
const flicking = new Flicking.CrossFlicking("#flicking");
</script>

Using the Methods

You can use methods that exist in Flicking.

Due to CrossFlicking using a different panel structure, methods that manipulate panels such as append, prepend, insert, and remove are not available in CrossFlicking.

Listening to Events

You can listen to events from the Flicking inside each Panel.
Each event has a mainIndex: number property, which is the index of the Panel including Flicking.

Also sideIndex: number property has been added to the events that notify index changes.
You can get the side index of the Flicking when the following events are fired.

<div id="flicking" class="flicking-viewport">
...
</div>

<script>
const flicking = new Flicking.CrossFlicking("#flicking");

flicking.on("changed", (e) => {
console.log(`Main Flicking index changed to ${e.index}`);
});

flicking.on("sideChanged", (e) => {
console.log(`Side Flicking ${e.mainIndex} index changed to ${e.index}`);
});
</script>

Options

class CrossFlicking extends Flicking
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
sideOptionsFlickingOption✔️{}Options for Vertical Flicking instances.
preserveIndexboolean✔️truePreserves the previous vertical index when the horizontal index changes.
disableSlideOnHoldboolean✔️truePrevents horizontal and vertical Flicking from being dragged at the same time.
disableIndexSyncboolean✔️falsePrevents index changes in the horizontal flicking from changing the index in the vertical flicking.