- From: Harmon S. Nine <hnine@netarx.com>
- Date: Wed, 09 Oct 2002 15:47:59 -0400
- To: www-svg@w3.org
Hi all. Does anyone have a better solution for doing this? I'm using the adobe SVG and was wondering how to display text in an SVG document that indicates that a given (relatively long) task is in progress and the user should wait ... He're the scenario. On a mousemove event, I'm hiding all text in the document to improve dynamic performance. However, hiding all of the text takes a while (a second or two). So, in the event-handler for mousemove, I'd like to update a "status" text element (that is not hidden :-) to say "Hiding text elements -- please wait ..." just before the operation(s) that hide the text. Here's a code snippet: function handleMouseMove(event) { status.nodeValue = "Hiding text elements -- please wait ..."; /* HIDE THE TEXT */ for(ix = textNodes.length ; --ix >= 0 ;) { textNodes[ix].displayAttr.value = "none"; } } The problem is that the SVG display does not update the "status" text element with this message until the entire event handler has executed, i.e. including the text-hiding operations. Thus what the user experiences is a few seconds of unresponsiveness, followed by the text being hidden and the "status" text saying "Hiding text elements -- please wait ...", which isn't very helpful. The only solution I've found is to split the event handler into two functions. One function updates the "status" text element and then schedules the second function (which hides the text elements) to run 50 milliseconds later via setTimeout. Apparently, 50 milliseconds is enough time for the SVG display to update. Here's the code: function handleMouseEvent(event) { status.nodeValue = "Hiding text elements -- please wait ..."; setTimeout("hideText()", 50); } function hideText() { /* HIDE THE TEXT */ for(ix = textNodes.length ; --ix >= 0 ;) { textNodes[ix].displayAttr.value = "none"; } } This is IMHO a horrible kludge, but its the only thing that works. If anyone has a better solution, I'd be most appreciative. :-) TIA -- Harmon S. Nine
Received on Wednesday, 9 October 2002 15:48:51 UTC