Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

is this recursive call safe

 
J. Kevin Robbins
Bartender
Pie
Posts: 1793
20
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This request is for a page that will be displayed as one of a series of pages in kiosk mode. The page will display for about 20 seconds before the next page in the sequence. User has requested that the background "pulse" or animate several shades of red in order to draw attention to the important message on the page. Here's what I've come up with.



I have two concerns. First, is this sort of recursive call safe or is it just going to consume memory until the browser crashes? I've seen lots of examples that use this kind of code, but that doesn't mean it's a good idea. If it's a bad idea, what's the alternative?

Second, the background goes white momentarily at the end of the loop before starting the loop again and I can't figure out why. I'm watching the style code in firebug and at the end of the loop it says "style=backgroundColor: rgb{165, 000, 000}". I never see it go to rgb(255, 255, 255} even if I increase the time delay.



 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64971
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the page refreshes every 20 seconds, I don't think you have any memory leak worries. (Except maybe in older versions of IE.)

If you are concerned about the recursive nature, you should be using the effects queue in any case. (See the .queue() method.)
 
J. Kevin Robbins
Bartender
Pie
Posts: 1793
20
Chrome Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I'll read up on the effects queue. I remember seeing mention of that in JQIA, but it was over my head at the time. I've grown a little since then.

I don't suppose you have any thoughts on that momentary switch to a white background? I've slowed it down to 2000 ms between transitions and still can't see anything that sets the background to anything other than the values I've defined. Same in Firefox or IE.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64971
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Re: white flash. Not off the top of my head.

Give the section on queueing in chapter 5 another go! Yehuda thinks it's the best explanation of jQuery queueing out there, and I'm not gonna argue with him.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic