question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to drag alpha

See original GitHub issue
import {SketchPicker} from 'react-color'

<SketchPicker/>

alpha slider unable to work

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:7

github_iconTop GitHub Comments

4reactions
Dror-Barcommented, Sep 1, 2020

@dmitriy-komarov try this:

const decimalToHex = (alpha: number) => alpha === 0 ? '00' : Math.round(255 * alpha).toString(16)

const handleColorChange = (color: ColorResult) => {
   const hexCode = `${c.hex}${decimalToHex(c.rgb.a)}` 
}

Solution from the thread I linked.

0reactions
Dongd0825commented, Aug 25, 2021

@dmitriy-komarov try this:

const decimalToHex = (alpha: number) => alpha === 0 ? '00' : Math.round(255 * alpha).toString(16)

const handleColorChange = (color: ColorResult) => {
   const hexCode = `${c.hex}${decimalToHex(c.rgb.a)}` 
}

Solution from the thread I linked.

enhance version

const decimalToHex = (alpha: number) => {
     let aHex = Math.round(255 * alpha).toString(16);
     return alpha === 0 ? '00' : aHex.length < 2 ? `0${aHex}` : aHex;
}
const handleColorChange = (color: ColorResult) => {
  const hexCode = `${color.hex}${decimalToHex(color?.rgb?.a ?? defaultAlpha)}`;
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I Apply an Alpha With Just A Click? Seems I Need to Drag ...
I am wondering if there is a way to apply just one instance of an alpha to the surface of the mesh by...
Read more >
Can't move alpha with DragRect and can't rotate with ... - Reddit
I can't get the position right with my alpha using these. Anything I'm doing wrong? Sorry I'm still very new to zbrush.
Read more >
Drag and Drop File Upload Control
You can upload files to either Amazon S3 or to your Alpha Anywhere server by dragging and dropping files onto a 'drag drop...
Read more >
Help | Aggie.io
View · hold. Space. to be able to drag canvas using mouse and zoom using mouse wheel (hold Ctrl to zoom in or...
Read more >
Unable to drag navigation tabs – IDEs Support (IntelliJ Platform)
If it's called by some setting then you may loose only one of the setting config files (although it still needs to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found