Opened 13 years ago

Closed 12 years ago

#2460 closed defect (fixed)

dojo.lfx.html.propertyAnimation not handling color curves correctly

Reported by: r.j.coon@… Owned by: Bryan Forbes
Priority: high Milestone:
Component: lfx Version: 0.4.1
Keywords: Cc:
Blocked By: Blocking:

Description

When using dojo.lfx.html.propertyAnimation in Firefox, the following code is executed against properties with color values:

for(var j = 0 ; j < prop.startRgb.length ; j++){
    value += Math.round(((prop.endRgb[j] - prop.startRgb[j]) * n) + prop.startRgb[j]) + (j < prop.startRgb.length - 1 ? "," : "");
}

(src/lfx/html.js line 146)

The problem is at "+ prop.startRgb[j]"--in Firefox (v2.0.0.1), prop.startRgb[j] is treated as a string, not an integer, so the value is concatenated onto the result of "((prop.endRgb[j] - prop.startRgb[j]) * n)" instead of added to its value.

As a workaround, wrapping prop.startRgb[j] in parseInt() works, but I suspect the dojo.gfx.color.Color.toRgb() method should really be returning an array of integers and not strings in the first place.

Change History (3)

comment:1 Changed 13 years ago by lakin@…

I think I may have run into the same problem. The problem is that in dojo.gfx.extractRGB there exists this code:

{{{ if( color.indexOf("rgb") == 0 ) {

var matches = color.match(/rgba*((d+), *(d+), *(d+)/i); var ret = matches.splice(1, 3); return ret;

} else {

...

}

}}}

But in firefox, this returns strings instead of numbers ... I'm not certain if this is a bug in firefox or dojo. But it does make for some very wierd color curves when using strings to specify the color, which is what happens sometimes when dynamically getting the color from the style of a particular node. For me, this is also present in 0.4.2

comment:2 Changed 13 years ago by lakin@…

Sorry, but I clicked submit before preview and didn't notice the formatting issue. Here is the code again, but formatted correctly.

if( color.indexOf("rgb") == 0 ) {
  var matches = color.match(/rgba*((d+), *(d+), *(d+)/i); var ret = matches.splice(1, 3); return ret;
} else {
 ...
}

comment:3 Changed 12 years ago by Adam Peller

Resolution: fixed
Status: newclosed

color animation was rewritten for 0.9 and seems to work now. The dojo.Color code does a cast to Number for each component.

Note: See TracTickets for help on using tickets.