Ticket #5163 (closed defect: wontfix)

Opened 8 months ago

Last modified 7 weeks ago

[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
};

Attachments

dojox.fx._base.patch (1.5 kB) - added by guest 8 months ago.
Patch to restore highlight behavior lost between 0.4.3 and 1.0

Change History

follow-up: ↓ 2   Changed 8 months ago by dante

  • status changed from new to assigned
  • owner changed from ttrenka to dante
  • milestone changed from 1.0.1 to 1.1

hey that's great but a couple of things:

a) who are you? we can't muck too much with it without a CLA on file and b) .diff's attached are soooo much easier to visualize changes made without having to dig around. they are the prefered method of submission ... though you have to "make the ticket", then go back and "attach file" ... c) unhighlight didn't get ported (it existed didn't it?) ... isn't the new highlight function (1.0) worlds different wrt to API than the 0.4?

Changed 8 months ago by guest

Patch to restore highlight behavior lost between 0.4.3 and 1.0

in reply to: ↑ 1   Changed 8 months ago by guest

Replying to dante:

a) who are you? we can't muck too much with it without a CLA on file and

Sorry about that. Haven't done the CLA yet, but figured it might not be needed since the code is basically from the 0.4.3 implementation anyway (just worked into the new function).

b) .diff's attached are soooo much easier to visualize changes made without having to dig around. they are the prefered method of submission ... though you have to "make the ticket", then go back and "attach file" ...

OK, I attached a diff but it seems to be in the wrong format because there's no preview?

c) unhighlight didn't get ported (it existed didn't it?) ...

You're right, it did exist.

Highlight can be used for the spotlight effect (from Yahoo! Design Pattern Library) to "call attention to where a data value or content has changed within the interface", where the background color highlight would appear instantly and then fade out until the original background is restored.

The unhighlight of 0.4.3 seems to start at the current background and animate the background color to some other color, and leave it there. I suppose it didn't get ported because it was viewed as needed less?

isn't the new highlight function (1.0) worlds different wrt to API than the 0.4?

So much in 1.0 is worlds different than 0.4. The highlight API is different because of the way the animation API has changed, I think, but I figure that doesn't necessarily mean the original functionality cannot still be maintained.

  Changed 8 months ago by guest

Just had a quick look at the patch, was it tested thoroughly on all browsers? In any case, it needs unit tests to support that it works correctly. If I can remember, the previous code has different behavior on different browsers.

Will have a look in the upcoming days. I ported the highlight from dojo so it works well and did leave out the unhiglight which seemed confusing and redundant.

jbondc

  Changed 8 months ago by dante

  • summary changed from dojox.fx.highlight missing functionality that was in 0.4.3 to [dojox][patch][no cla] fx.highlight missing functionality that was in 0.4.3

  Changed 5 months ago by dante

  • milestone changed from 1.1 to 1.2

  Changed 7 weeks ago by dante

  • status changed from assigned to closed
  • resolution set to wontfix
  • description modified (diff)

i'm going to argue that the functionality isn't sorely missed, and not vital. please reopen with patch if the need is great.

Note: See TracTickets for help on using tickets.