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

option to disable brightness bar And option to render it to a different element #13

Closed
ringofhealth opened this issue Oct 20, 2017 · 11 comments

Comments

@ringofhealth
Copy link

Hey, this relate to issue #9, in addition to have the ability to disable the brightness bar, is it also possible to draw the brightness canvas as a separate modular html element? cause the current layout may not be applicable to all applications.

@ringofhealth
Copy link
Author

@jaames any ideas?

@jaames
Copy link
Owner

jaames commented Oct 25, 2017

Hi, sorry for the slow response!

My initial thought is that it would "break" a couple of things, like:

  • When setting up a color picker, you give it a single CSS selector/HTML element to use as a container, it would be a bit confusing if the slider canvas is somewhere outside this container, no?
  • The color picker's width and height options, which are used for the canvas size, would no longer be meaningful if two canvases are used.

Maybe you could provide more detail? A practical use-case would really be appreciated. :)

@ringofhealth
Copy link
Author

ringofhealth commented Oct 29, 2017

Ah okay, if its gonna break things, then perhaps the option to disable the brightness bar would be sufficient then.

My reasoning behind this is essentially, if the UI of an given application separates the ability of the user to change brightness and the actual color of a given element, then the current rendered canvas would not be applicable. Thats essentially whats happening to me right now. They can't be rendered like the way they are presented right now.

If its too much hassle to have the ability to render them out in seperate elements. Given the option to disable the brightness bar and the event listener present on color changes. Then I can have my own slider to change the brightness by itself and utilize the hue and sat aspect of the color wheel

@jaames
Copy link
Owner

jaames commented Oct 29, 2017

I'll definitely consider optionally disabling the brightness slider, and I will experiment to see if I can get elements to render to seperate elements too. iro 3.0.0 is out now, and with it I've switched to using SVG for the UI instead of the canvas API. Perhaps it will be easier to do with SVG? ¯_(ツ)_/¯

If it's super important and you're okay with a hacky solution, with the latest version of the library you can hide the brightness slider with CSS:

.iro__slider {
     display: none;
     visibility: hidden;
     pointer-events: none;
}

Then also remove the reference to it from the color picker's internal UI element list, which will stop it from picking up mouse events on the hidden slider:

colorPicker.ui.slice(1, 1);

@ringofhealth
Copy link
Author

Wow I see you have totally reworked this lib, awesome!! I tried your method of hiding it, with css and the js, but it seems like the brightness event is still being picked up. Any other way around this?

@jaames
Copy link
Owner

jaames commented Oct 31, 2017

Yep!

Ah whoops, I think I made a mistake. The JS should be ui.splice(1, 1). Basically, we want to remove the second item from the color picker's ui array (the first item is the hue/sat wheel).

@ringofhealth
Copy link
Author

ah you are absolutely right! with the brightness control gone, anyway I can center the circle svg element inside the container by pure css?

@jaames
Copy link
Owner

jaames commented Nov 1, 2017

I suppose you could try force-cropping the SVG by taking a couple of pixels off the height:

#exampleWrapper svg {
     height: 200px !important;
}

Something like that perhaps? It is a bit difficult to write a CSS selector that targets the SVG element, I should do something about that. :P

@Lehoczky
Copy link

Because this is a dynamically injected html element, for anyone using Angular, the css should look like this:

:host /deep/ .iro__slider {
  display: none;
  visibility: hidden;
  pointer-events: none;
}

@jaames
Copy link
Owner

jaames commented Jan 25, 2019

With the latest version of iro.js (version 4.0.0), there is a new layout config option. This can be used to specify which controls are used:

<html>
  <head>
    <script src="https://unpkg.com/@jaames/iro/dist/iro.js"></script>
  </head>
  <body>
    <div id="color-picker-mount"></div>
    <script>
       var colorPicker = new iro.ColorPicker("#color-picker-mount", {
         width: 300,
         layout: [
            { component: iro.ui.Wheel, options: {} }
         ]
       });
    </script>
  </body>
</html>

Check out the Custom Layout documentation for more information on how this works.


Additionally, each UI component is now a seperate SVG element with its own events, etc. If you want to render the slider in a seperate element, you should be able to do some simple DOM manipulation to move it elsewhere. :)

Sorry for taking so long to find a proper way to do this. ':)

@jaames jaames closed this as completed Jan 25, 2019
@jaames
Copy link
Owner

jaames commented Feb 22, 2019

Version 4.0.0 is live, so this is now possible with the newest version of the library. I've edited my previous comment with more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants