ionic-team / ionic-team/ionic-framework

feat: Add event for ion-item-sliding open/close state change

Open
#18,533 2 comments 4 reactions 0 assignees View on GitHub
package: core type: feature request
Dominant language
TypeScript
Stars
52.7k
Forks
13.3k
Avg merge
1d 15h
Merged PRs (30d)
51

Description

# Feature Request

**Ionic version:**

[x] **4.x**

**Describe the Feature Request**

Ionic should provide an event(s) for developers that allows them to determine when an `` has been fully opened or closed.

**Describe Preferred Solution**

Provide event(s) `ionOpen` and/or `ionClose` emitted when the slider reaches a fully open or closed position. It would only emit once even if the user has not removed their finger from the slider, but the slider has moved to an "open/closed" position.

For example, if the user moves the slider from position 0 to position 1.0, the event would fire once.

If the user moves the slider from position 0 -> 1 and back to 0, the event would fire twice (once on "open" and once on "close").

If the user moves the slider from position 0 -> 0.5 -> 0, the event would *not* fire (because there was not a change from open to closed or vice-versa.

**Describe Alternatives**

The current implementation allows developers to use the `ionDrag` event (https://ionicframework.com/docs/api/item-sliding#events), but that event emits any time the position changes and is not definitive (i.e. you could drag a slider halfway to open/closed and the event would still fire).

Alternatively you could also use the `getSlidingRatio` and set it to a specific value. However, this is also not definitive as you could drag from 0 -> 0.75 -> 0 which should not count as a close/open.

**Related Code**

I do not have a code sample at this time.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.