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.
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
- JavaScript (Group)
- JavaScript (Data attribute)
- React (Group)
- React (Data attribute)
<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.
- sideHoldStart extends holdStart
- sideHoldEnd extends holdEnd
- sideMoveStart extends moveStart
- sideMove extends move
- sideMoveEnd extends moveEnd
- sideWillChange extends willChange
- sideChanged extends changed
- sideWillRestore extends willRestore
- sideRestored extends restored
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.
- changed event
- willChange event
- JavaScript
- React
<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
PARAMETER | TYPE | OPTIONAL | DEFAULT | DESCRIPTION |
---|---|---|---|---|
sideOptions | FlickingOption | ✔️ | {} | Options for Vertical Flicking instances. |
preserveIndex | boolean | ✔️ | true | Preserves the previous vertical index when the horizontal index changes. |
disableSlideOnHold | boolean | ✔️ | true | Prevents horizontal and vertical Flicking from being dragged at the same time. |
disableIndexSync | boolean | ✔️ | false | Prevents index changes in the horizontal flicking from changing the index in the vertical flicking. |