Reducing Conflict
When you have a lot of animation, scrolling, and so forth in a page, it can get a little distracting
and possibly overwhelming for the user. Also, if the answers in your FAQ vary greatly in length,
you can end up with some very strange scrolling behaviors as they shrink and enlarge.
It would be nice to have an orderly means of triggering events so you don??™t have this sort
of conflict. Open questions should have time to close before the page begins to scroll, and the
scrolling should come to a halt before the new question opens up.
One way of accomplishing this is to set up a process queue and instruct methods to wait
their turn. You??™ll implement it using two helper methods and a few of the properties of the FAQ
object that you already defined.
1. You??™ll start with FAQ.processing(). This simple method will return true if there is anything
in the FAQ.processes queue and false if there isn??™t. It will be the indicator to a
method about whether it is safe to proceed with carrying out its business:
processing: function(){
trace( 'current processes: ' + this.processes.toString() );
return ( this.processes.length > 0 ) ? true : false;
},
CHAPTER 8 n CASE STUDY: FAQ FACELIFT 182
2. FAQ.wait() accepts an argument of the method name that needs to wait and sets a
timer to try that method again in 10ms:
wait: function( method ){
trace( 'waiting to run this.' + method + '()' );
this.
Pages:
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258