Skip to content

Events returns wrong direction on circular when calling prev() on first panel or next() on last panel. #854

@fully-john

Description

@fully-john

Description

I have a circular flicking with strict moveType that consists of three panels, all of them full screen.

I have buttons to call next() and previous() as well as the normal swipe motion.
However, when I'm on the first panel (index 0) and trigger prev(), the direction in WillChangeEvent.direction is "NEXT". However, if it's triggered by a swipe, the event returns the correct direction (in this case: "PREV"). The same happens in the opposite side of the panels. e.g. when I'm on the last panel and call next(), the WillChangeEvent.direction is "PREV". If triggered by swipe, the direction will be correct.

Steps to check or reproduce

The following code returns wrong direction on .prev() at first panel and next() on last panel:

<SomeButton onClick={() => await flickRef.current.prev()} />
<Flicking
          ref={flickRef}
          circular
          duration={600}
          threshold={40}
          align={"center"}
          onWillChange={(e: WillChangeEvent) => {
            console.log("WILL CHANGE", e);
            flickStart(e.index, e.direction);
          }}
          onChanged={(e: ChangedEvent) => {
            console.log("DID CHANGE", e);
            flickEnd(e.index);
          }}
          moveType={"strict"}
          changeOnHold={true}
        >
...
</Flicking>

Also, thanks a bunch for all the work you put in. Great package overall!

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions