jaames / jaames/iro.js

Possible to determine element from color:change etc.

Open
#245 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.5k
Forks
91
PR merge metrics
No merged PRs in 30d

Description

When referencing a [ColorPicker](https://iro.js.org/colorPicker_api.html) instance, we can call the [el](https://iro.js.org/colorPicker_api.html#el) method on the object to get the HTML element that the color picker was mounted to. When we add callbacks to the color picker, for example color:change or input:end, we are passed a [Color](https://iro.js.org/color_api.html) instance, that has properties describing the current color state of the picker.

My question however, is whether it is possible to determine within the callback function which ColorPicker this Color object corresponds to? The end goal being to grab some data-* attributes from the HTML element the color picker was mounted to in order to perform some action that is specific to this color picker (as opposed to other color pickers which may be rendered on the same page). Can this be done? I can't find a way to reference the element or ColorPicker instance from the Color instance, and don't see it listed in the Colors API, but it seems that this would be a common use case, so perhaps I am missing something.

Thanks!

Contributor guide

Open the contributing guide

Research direction

Start with the ColorPicker API's el method and the color:change and input:end callback signatures described in the issue. Trace how the Color instance reaches callbacks and determine whether the picker or mounted element can be identified; done means the supported behavior and any required API or documentation changes are clearly defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.