Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`tapselect` and `tapunselect` events #1977

Closed
jri opened this issue Sep 18, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@jri
Copy link

commented Sep 18, 2017

Issue type

Feature request

Spec

  • tapselect : when an element is selected by a tap gesture
  • tapunselect : when an element is unselected by a tap elsewhere

Motivation

See below OP:

--

Is there a way to set an element's selection state (like ele.select() does) but without firing a select event?

This is useful when the selection state must be restored programmatically e.g. on application launch or history pop (in a scenario when each interactive selection causes a history push).

In these cases the application must restore the (visual) state programmatically but without triggering the actions usually caused by interactive selection.

@maxkfranz

This comment has been minimized.

Copy link
Member

commented Sep 19, 2017

No, mutating the selected state emits a select or unselect event. It doesn't matter whether it originated from UI or whether it originated from just API calls.

You need additional (gesture) events. It sounds like most of your app code shouldn't be listening to select directly. There are already box events, so it would probably suffice to add tapselect and tapunselect events. If you'd like to see these events in 3.3, please consider making a PR. We already have a full queue of features we're working on for that milestone.

@maxkfranz maxkfranz added this to the future milestone Sep 19, 2017

@maxkfranz maxkfranz changed the title Set element's selection state without firing a `select` event `tapselect` and `tapunselect` events Sep 19, 2017

@jri

This comment has been minimized.

Copy link
Author

commented Sep 21, 2017

The hint about not listening to the select/unselect event was fruitful. Now I kind of simulate tapselect and tapunselect by interpreting plain tap-node/edge and tap-background events. This solved my problem.

Thank you for helpful response!

@maxkfranz

This comment has been minimized.

Copy link
Member

commented Sep 21, 2017

I'm glad it's working for you, but there is probably value in having direct support in the lib as well. It would be clearer, and would support more cases. The selection mode can be set differently from default. Using selectionType: 'additive' would be different for tap, for example. Maybe it's select; maybe it's unselect.

@jri

This comment has been minimized.

Copy link
Author

commented Sep 22, 2017

I fully agree. Having tapselect/tapunselect events in the library would be good. Unfortunately at the moment I can't make a PR. Sorry.

@maxkfranz maxkfranz modified the milestones: future, 3.4.0 Jan 15, 2019

@maxkfranz maxkfranz self-assigned this Jan 17, 2019

maxkfranz added a commit that referenced this issue Jan 18, 2019

`tapselect` and `tapunselect` events
Events:
 * `tapselect` : when an element is selected by a tap gesture
 * `tapunselect` : when an element is unselected by a tap gesture on another element

Changes:
- Private: Add support for emitting additional events in switch functions (like `ele.select()`)
- Public: Add array support for `emit()`, e.g. `ele.emit(['event1', 'event2', 'event3'])`
- Public: Add new events
- Private: Make `unselect` and `tapunselect` events happen after `tap`.  That order seems to make more sense.

Ref : #1977 #2273

@maxkfranz maxkfranz closed this Jan 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.