Ticket #5163 (closed defect: wontfix)
[dojox][patch][no cla] fx.highlight missing functionality that was in 0.4.3
| Reported by: | guest | Owned by: | dante |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.2 |
| Component: | Dojox | Version: | 1.0 |
| Severity: | normal | Keywords: | fx highlight |
| Cc: |
Description (last modified by dante) (diff)
dojox.fx.highlight in 1.0 is missing some functionality that was in dojo.lfx.html.highlight in 0.4.3.
1) When using dojox.fx.highlight on a transparent node (a node with no background color) that is contained within a parent that does have a background, the highlight effect fades to white instead of to the "inherited" background color and then becomes transparent again. This can also be seen in the test#3 on page dojox/fx/tests/test_highlight.html, where the node appears over the body's background image. In 0.4.3, dojo.lfx.html.highlight handled this by calling dojo.html.getBackgroundColor(node) to get the endColor for the fade.
2) If you want the startColor highlight to remain for a little while before starting to fade out, in 0.4.3 you were able to specify a delay as the argument to play(). This worked because dojo.lfx.html.highlight set the startColor as part of beforeBegin. But in 1.0 this is missing, so specifying a delay only means there is a pause before you see the startColor and then it begins to fade immediately.
Below is an updated version of dojox.fx.highlight that restores this functionality using code based on the 0.4.3 implementation:
dojox.fx.highlight = function(/*Object*/ args){
// summary: Highlight a node
// description:
// Returns an animation that sets the node background to args.color
// then gradually fades back the original node background color
//
// example:
// dojox.fx.highlight({ node:"foo" }).play();
var node = (args.node = dojo.byId(args.node));
args.duration = args.duration || 400;
// Assign default color light yellow
var startColor = args.color || '#ffff99';
var endColor = dojo.style(node, "backgroundColor").toLowerCase();
var bgImage = dojo.style(node, "backgroundImage");
var wasTransparent = (endColor == "transparent" || endColor == "rgba(0, 0, 0, 0)");
if ( wasTransparent ) {
// get inherited background color to use as endColor
var pNode = node;
do {
endColor = dojo.style(pNode , "backgroundColor");
if (endColor.toLowerCase() == "rgba(0, 0, 0, 0)") {
endColor = "transparent";
}
if (pNode == document.getElementsByTagName("body")[0]) {
pNode = null;
break;
}
pNode = pNode .parentNode;
} while (pNode && (endColor == "transparent"));
}
var anim = dojo.animateProperty(dojo.mixin({
properties: {
backgroundColor: { start: startColor, end: endColor }
}
}, args));
dojo.connect(anim, "beforeBegin", anim, function(){
if (bgImage) {
dojo.style( node, "backgroundImage", "none" );
}
// set startColor beforeBegin so can set delay on play()
dojo.style( node, "backgroundColor", startColor );
});
dojo.connect(anim, "onEnd", anim, function(){
if (bgImage) {
dojo.style( node, "backgroundImage", bgImage );
}
if ( wasTransparent ) {
dojo.style( node, "backgroundColor", "transparent" );
}
});
return anim; // dojo._Animation
};