Socket
Socket
Sign inDemoInstall

angular-radial-color-picker

Package Overview
Dependencies
2
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    angular-radial-color-picker

Angular-ready radial color picker with some sleek animations.


Version published
Weekly downloads
71
decreased by-31.07%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

Angular Radial Color Picker

Material design(ish) color picker with some animations sprinkled on top.

The color picker has been developed treating the mobile devices as first class citizens:

  • Supports touch devices
  • Responsive size
  • Blazing fast GPU accelerated animations

The only dependency of Angular Radial Color Picker is Propeller for rotating the knob.

Demos

Color Picker in a modal window - GitHub Pages

Barebones example - Codepen

Install

NPM

Color Picker on npm

npm install angular-material-color-picker

Bower

  • Download Propeller
  • Download the color picker as usual
bower install angular-material-color-picker

Back To Top

And in your html:

<head>
    <!-- Include the css -->
    <link href="path/to/angular-radial-color-picker/dist/css/color-picker.min.css" rel="stylesheet">
</head>
<body>
    <!-- The actual color picker component -->
    <color-picker ng-model="$ctrl.initialColor" on-select="$ctrl.onSelect(color)"></color-picker>

    <!-- Angular Radial Color Picker Dependencies -->
    <script src="path/to/propeller.min.js"></script>
    <script src="path/to/angular/angular.min.js"></script>

    <!-- Include the package -->
    <script src="path/to/angular-radial-color-picker/dist/js/color-picker.min.js"></script>
</body>

Once you have all the necessary assets installed, add color.picker.core as a dependency for your app:

angular.module('myApp', ['color.picker.core']);

Back To Top

API

<color-picker></color-picker> component has 2 attributes:

  • ng-model Object for initializing/changing the color of the picker (optional). Properties:
NameTypeDefaultDescription
rednumber255An integer between 0 and 255
greennumber0An integer between 0 and 255
bluenumber0An integer between 0 and 255
  • on-select callback which gets triggered when a color is selected (optional, see Events). The passed function is invoked with one argument which is an object with the following properties:
NameTypeDescription
hexstringA hexidecimal string
rgbaobjectRGBA color model
hslaobjectHSLA color model
  • RGBA Color model:
NameTypeDefaultDescription
rednumber255An integer between 0 and 255
greennumber0An integer between 0 and 255
bluenumber0An integer between 0 and 255
alphanumber1Transparency. A number between 0 and 1
  • HSLA Color model:
NameTypeDefaultDescription
huenumber0A number between 0 and 359
saturationnumber100A number between 0 and 100
luminositynumber50A number between 0 and 100
alphanumber1A number between 0 and 1

Back To Top

Events

For maximum flexibility the component utilizes the pub/sub pattern. For easier communication a set of events are provided that can even programatically open or close the picker without interacting with the UI. All events are published/subscribed at the $rootScope so that sibling components can subscribe to them too. All events carry the current (selected) color in the event data payload.

  • color-picker.show - Fires when the color picker is about to show and before any animation is started.
  • color-picker.shown - Fires when the color picker is shown and has finished animating.
  • color-picker.selected - Fires when a color is selected via the middle selector. Event is fired right before hide.
  • color-picker.hide - Fires when the color picker is about to hide and before any animation is started.
  • color-picker.hidden - Fires when the color picker is hidden and has finished animating.

Example:

// Listening for something interesting to happen:
$rootScope.$on('color-picker.selected', function(ev, color) {
    // a) using HSLA color model
    vm.selectedColor = 'hsla(' + color.hsla.hue + ', ' + color.hsla.saturation + '%, ' + color.hsla.luminosity + '%, ' + color.hsla.alpha + ')';

    // b) using RGB color model
    vm.selectedColor = 'rgb(' + color.rgb.red + ', ' + color.rgb.green + ', ' + color.rgb.blue + ')';

    // c) plain old hex
    vm.selectedColor = '#' + color.hex;
});

// The good'n'tested "poke-it-with-a-stick" method:
$rootScope.$broadcast('color-picker.open');

Back To Top

Styling/sizing

The color picker has a default width/height of 280px, but can also be sized via CSS. For example:

color-picker {
    width: 350px;
    height: 350px;
}

Back To Top

Contributing

TBD

Back To Top

Keywords

FAQs

Last updated on 28 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc