-
Notifications
You must be signed in to change notification settings - Fork 14
/
angular-colorthief.min.js
3 lines (3 loc) · 1.08 KB
/
angular-colorthief.min.js
1
2
3
angular.module("ngColorThief",[]).provider("$colorThief",[function(){var f=new ColorThief,c,d,b=!1;this.setDefaultQuality=function(a){c=a};this.setDefaultColorCount=function(a){d=a};this.setReturnObjects=function(a){b=a};this.$get=[function(){function a(a){return b?{r:a[0],g:a[1],b:a[2]}:a}return{getColor:function(g,b){return a(f.getColor(g,b||c))},getPalette:function(b,e,h){b=f.getPalette(b,e||d,h||c);for(e=b.length-1;0<=e;e--)b[e]=a(b[e]);return b}}}]}]).directive("colorThief",["$parse","$colorThief",
function(f,c){return{restrict:"A",scope:{dominant:"=colorThiefDominant",palette:"=colorThiefPalette"},link:function(d,b,a){if("IMG"!==angular.uppercase(b[0].tagName))throw Error("The colorThief directive has to be applied to an IMG tag.");if(angular.isDefined(a.crossorigin)||angular.isDefined(a.crossOrigin))b[0].crossOrigin=a.crossorigin||a.crossOrigin||"Anonymous";var g=a.colorThiefPaletteCount?f(a.colorThiefPaletteCount)():void 0;b.on("load",function(){d.$apply(function(){a.colorThiefDominant&&
(d.dominant=c.getColor(b[0]));a.colorThiefPalette&&(d.palette=c.getPalette(b[0],g))})})}}}]);