Skip to content

Commit

Permalink
0.20.0, access current element in onChange
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jun 4, 2023
1 parent 8f8c949 commit dedc090
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@melloware/coloris",
"version": "0.19.1",
"version": "0.20.0",
"description": "A lightweight and elegant color picker.",
"author": "Momo Bassit",
"contributors": [
Expand Down
14 changes: 7 additions & 7 deletions src/coloris.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* NPM: https://github.com/melloware/coloris-npm
*/

return ((window, document, Math) => {
return ((window, document, Math, undefined) => {
const ctx = document.createElement('canvas').getContext('2d');
const currentColor = { r: 0, g: 0, b: 0, h: 0, s: 0, v: 0, a: 1 };
let container, picker, colorArea, colorAreaDims, colorMarker, colorPreview, colorValue, clearButton, closeButton,
Expand Down Expand Up @@ -81,7 +81,7 @@ return ((window, document, Math) => {

// document.body is special
if (container === document.body) {
container = null;
container = undefined;
}
}
break;
Expand Down Expand Up @@ -458,7 +458,7 @@ return ((window, document, Math) => {
// Revert the color to the original value if needed
if (revert) {
// This will prevent the "change" event on the colorValue input to execute its handler
currentEl = null;
currentEl = undefined;

if (oldColor !== prevEl.value) {
prevEl.value = oldColor;
Expand Down Expand Up @@ -491,7 +491,7 @@ return ((window, document, Math) => {
}

// This essentially marks the picker as closed
currentEl = null;
currentEl = undefined;
}
}

Expand Down Expand Up @@ -546,10 +546,10 @@ return ((window, document, Math) => {
}

if (settings.onChange) {
settings.onChange.call(window, color);
settings.onChange.call(window, color, currentEl);
}

document.dispatchEvent(new CustomEvent('coloris:pick', { detail: { color } }));
document.dispatchEvent(new CustomEvent('coloris:pick', { detail: { color: color, currentEl: currentEl } }));
}

/**
Expand Down Expand Up @@ -922,7 +922,7 @@ return ((window, document, Math) => {
function init() {
if (document.getElementById('clr-picker')) return; //** DO NOT REMOVE: Prevent binding events multiple times
// Render the UI
container = null;
container = undefined;
picker = document.createElement('div');
picker.setAttribute('id', 'clr-picker');
picker.className = 'clr-picker';
Expand Down

0 comments on commit dedc090

Please sign in to comment.