11/*!
2- * angularjs-color-picker v1.1.4
2+ * angularjs-color-picker v1.1.5
33 * https://github.com/ruhley/angular-color-picker/
44 *
55 * Copyright 2016 ruhley
66 *
7- * 2016-06-07 10:40:11
7+ * 2016-06-21 07:56:41
88 *
99 */
1010if ( typeof module !== "undefined" && typeof exports !== "undefined" && module . exports === exports ) {
@@ -19,7 +19,7 @@ if (typeof module !== "undefined" && typeof exports !== "undefined" && module.ex
1919
2020( function ( ) {
2121 'use strict' ;
22- console . log ( ) ;
22+
2323 var colorPicker = function ( $document , $timeout ) {
2424 return {
2525 restrict : 'E' ,
@@ -378,57 +378,62 @@ console.log();
378378 //---------------------------
379379 // Update Positions And Colors On Elements
380380 //---------------------------
381+
381382 $scope . $watch ( 'swatchColor' , function ( ) {
382383 $scope . updateSwatchBackground ( ) ;
383384 } ) ;
384385
385- $scope . $watch ( 'huePos' , function ( newValue ) {
386+ $scope . huePosUpdate = function ( ) {
386387 var container = element [ 0 ] . querySelector ( '.color-picker-hue' ) ;
387388 var el = angular . element ( element [ 0 ] . querySelector ( '.color-picker-hue .color-picker-slider' ) ) ;
388389 var bounding = container . getBoundingClientRect ( ) ;
389390
390391 el . css ( {
391- 'top' : ( bounding . height * newValue / 100 ) + 'px' ,
392+ 'top' : ( bounding . height * $scope . huePos / 100 ) + 'px' ,
392393 } ) ;
393- } ) ;
394+ } ;
394395
395- $scope . $watch ( 'opacityPos' , function ( newValue ) {
396+ $scope . opacityPosUpdate = function ( ) {
396397 var container = element [ 0 ] . querySelector ( '.color-picker-opacity' ) ;
397398 var el = angular . element ( element [ 0 ] . querySelector ( '.color-picker-opacity .color-picker-slider' ) ) ;
398399 var bounding = container . getBoundingClientRect ( ) ;
399400
400401 el . css ( {
401- 'top' : ( bounding . height * newValue / 100 ) + 'px' ,
402+ 'top' : ( bounding . height * $scope . opacityPos / 100 ) + 'px' ,
402403 } ) ;
403- } ) ;
404+ } ;
404405
405- $scope . $watch ( 'lightnessPos' , function ( newValue ) {
406- var container = element [ 0 ] . querySelector ( '.color-picker-grid' ) ;
407- var el = angular . element ( element [ 0 ] . querySelector ( '.color-picker-grid .color-picker-picker' ) ) ;
408- var bounding = container . getBoundingClientRect ( ) ;
406+ $scope . lightnessPosUpdate = function ( ) {
407+ $timeout ( function ( ) {
408+ var container = element [ 0 ] . querySelector ( '.color-picker-grid' ) ;
409+ var el = angular . element ( element [ 0 ] . querySelector ( '.color-picker-grid .color-picker-picker' ) ) ;
410+ var bounding = container . getBoundingClientRect ( ) ;
409411
410- el . css ( {
411- 'top' : ( bounding . height * newValue / 100 ) + 'px' ,
412+ el . css ( {
413+ 'top' : ( bounding . height * $scope . lightnessPos / 100 ) + 'px' ,
414+ } ) ;
412415 } ) ;
413- } ) ;
416+ } ;
414417
415- $scope . $watch ( 'saturationPos' , function ( newValue ) {
416- var container = element [ 0 ] . querySelector ( '.color-picker-grid' ) ;
417- var el = angular . element ( element [ 0 ] . querySelector ( '.color-picker-grid .color-picker-picker' ) ) ;
418- var bounding = container . getBoundingClientRect ( ) ;
418+ $scope . saturationPosUpdate = function ( ) {
419+ $timeout ( function ( ) {
420+ var container = element [ 0 ] . querySelector ( '.color-picker-grid' ) ;
421+ var el = angular . element ( element [ 0 ] . querySelector ( '.color-picker-grid .color-picker-picker' ) ) ;
422+ var bounding = container . getBoundingClientRect ( ) ;
419423
420- el . css ( {
421- 'left' : ( bounding . width * newValue / 100 ) + 'px' ,
424+ el . css ( {
425+ 'left' : ( bounding . width * $scope . saturationPos / 100 ) + 'px' ,
426+ } ) ;
422427 } ) ;
423- } ) ;
428+ } ;
424429
425- $scope . $watch ( 'grid' , function ( newValue ) {
430+ $scope . gridUpdate = function ( ) {
426431 var el = angular . element ( element [ 0 ] . querySelector ( '.color-picker-grid' ) ) ;
427432
428433 el . css ( {
429- 'background-color' : newValue ,
434+ 'background-color' : $scope . grid ,
430435 } ) ;
431- } ) ;
436+ } ;
432437
433438 //---------------------------
434439 // HUE
@@ -476,6 +481,8 @@ console.log();
476481 $scope . huePos = 100 ;
477482 }
478483
484+ $scope . huePosUpdate ( ) ;
485+ $scope . gridUpdate ( ) ;
479486 $scope . update ( ) ;
480487 }
481488 } ;
@@ -529,6 +536,7 @@ console.log();
529536 $scope . opacityPos = 100 ;
530537 }
531538
539+ $scope . opacityPosUpdate ( ) ;
532540 $scope . update ( ) ;
533541 }
534542 } ;
@@ -591,6 +599,7 @@ console.log();
591599 $scope . saturationPos = 100 ;
592600 }
593601
602+ $scope . saturationPosUpdate ( ) ;
594603 $scope . update ( ) ;
595604 }
596605 } ;
@@ -610,6 +619,7 @@ console.log();
610619 $scope . lightnessPos = 100 ;
611620 }
612621
622+ $scope . lightnessPosUpdate ( ) ;
613623 $scope . update ( ) ;
614624 }
615625 } ;
0 commit comments