Comments (7)
I believe you are setting the value of #clr-color-value
before the color picker is properly initialized. Try this :
Coloris({
parent: '#e-color-picker',
alpha: true,
theme: 'large',
format: 'mixed',
inline: true
});
const setColorToGreen = () => {
document.querySelector('#clr-color-value').value = 'green';
document.querySelector('#clr-color-value').dispatchEvent(new Event('change', { bubbles: true }));
};
document.addEventListener('coloris:pick', event => {
console.log('New color', event.detail.color);
});
// Wait for the document to load first
if (document.readyState !== 'loading') {
setColorToGreen();
} else {
document.addEventListener('DOMContentLoaded', function () {
setColorToGreen();
});
}
from coloris.
Also, if all you need is to set the default color of the inline picker, just use the defaultColor
option:
Coloris({
parent: '#e-color-picker',
alpha: true,
theme: 'large',
format: 'mixed',
inline: true,
defaultColor: 'green'
});
from coloris.
@mdbassit thanks for your response. I don't believe the issue is with setting the defautl value. I get the same result even by just using the basic initializaiton and nothing elsle.
Coloris({
parent: '#e-color-picker',
alpha: true,
theme: 'large',
format: 'mixed',
inline: true,
defaultColor: 'green'
});
In my case when I try to select a color, the cursor position does not get updated. Awlays stays x=0, z=0, however 'coloris:pick' events still get fired.
from coloris.
That's quite strange! I'm unable to reproduce the issue, but it's likely that something is interfering with the calculation of the position of the mouse pointer. Can you maybe share the rest of your code or the link to a page where I can take a look at this in action?
from coloris.
Thanks @mdbassit ! I will try to debug the comming days and share a better example if I am unable to make it work.
from coloris.
Ok, I managed to make it work on a clear page.
Here are examples in case someone is interested.
<html>
<body style="margin: 0;padding: 0;">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/mdbassit/Coloris@latest/dist/coloris.min.css"/>
<script src="https://cdn.jsdelivr.net/gh/mdbassit/Coloris@latest/dist/coloris.min.js"></script>
<div style="display: flex; justify-content: center; align-items: center;height: 100%;">
<div id="e-color-container" style="border: 1px solid #000;position: relative;height: 400px;width: 400px;"></div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
Coloris({
parent: '#e-color-container',
inline: true,
alpha: true,
theme: 'large',
format: 'mixed',
defaultColor: '#fff'
});
document.addEventListener('coloris:pick', event => {
console.log('New color', event.detail.color);
});
});
</script>
</body>
</html>
and Preact
<html>
<body style="margin: 0;padding: 0;">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/mdbassit/Coloris@latest/dist/coloris.min.css"/>
<script src="https://cdn.jsdelivr.net/gh/mdbassit/Coloris@latest/dist/coloris.min.js"></script>
<script type="module">
import { html, Component, render, useEffect } from 'https://unpkg.com/htm/preact/standalone.module.js';
function App (props) {
useEffect(() => {
Coloris({
parent: '#e-color-container',
inline: true,
alpha: true,
theme: 'large',
format: 'mixed',
defaultColor: '#fff'
});
}, [])
return html`
<div style="display: flex; justify-content: center; align-items: center;height: 100%;">
<div id="e-color-container" style="border: 1px solid #000;position: relative;height: 400px;width: 400px;"></div>
</div>
`;
}
render(html`<${App} />`, document.body);
</script>
</body>
</html>
Thanks!
from coloris.
Will close the thread. Thanks!
from coloris.
Related Issues (20)
- Open method HOT 3
- clr-open-label not initialized on osX HOT 4
- Add 'Cancel' button (or any custom button) HOT 5
- Materializecss compatibility HOT 2
- Popup Input Issue HOT 3
- Mouse does not lineup on palette after scrolling in scrollable container HOT 3
- Include SCSS file with variables HOT 10
- Add support for CSS custom properties (variables) HOT 1
- Colorpicker wraps all input fields on page load HOT 5
- I would like to contribute sass/scss to the repository HOT 4
- ARIA: issue with Inline `#clr-color-marker` HOT 6
- Incorrect output value of alpha channel in 8-digit Hex Code HOT 8
- The color picker doesn't stick to the input it scrolls along HOT 2
- Option to not style the input element HOT 8
- Make `el` and `parent` options accept `Node` HOT 12
- colorArea doesn't handle right mouse button HOT 2
- Feature Request: Add Eyedropper HOT 2
- Missing info in docs about setting up thumbnails HOT 4
- Not showing in absolute positioned div HOT 2
- Alpha channel loses information HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coloris.