I must say I like your approach.

I was looking for something similar for my website a week or so ago and rolled 
my own solution which is nowhere near as elegant. 
(code at http://www.josephbauser.net/javascripts/application.js example use 
at... well the main site. If you do check it out, please be gentile it's very 
much a work in progress ;)

I definitely over thought the solution (forgot about Element.update for one).

Well done. :)

Joe

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Fabian
Lange
Sent: Tuesday, July 18, 2006 4:45 PM
To: rails-spinoffs@lists.rubyonrails.org
Subject: [Rails-spinoffs] script.aculo.us effect to update elements


Hi,
perhaps I am overseeing this but it seems that there is no easy way to set
up a queue with two effects (fade and appear) and in between exchange the
content.
So I have an application with static layout and just want to animate the
exchange of the content from the main div.

So I wrote my own effect. The nice thing is that this is now queue able.

Effect.Updater = Class.create();
Object.extend(Object.extend(Effect.Updater.prototype,
Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    var options = Object.extend({
      duration: 0.001,
      newContent: ''
    }, arguments[1] || {});
    this.start(options);
  },
  loop: function(timePos) {
    if(timePos >= this.startOn) {
      Element.update(this.element,this.options.newContent);
      this.cancel();
      return;
    }
  }
});

So I can now put this to the method I pass to onComplete of Ajax.Request

function reload_content(ajax){
  el = $('content');
  new Effect.Fade(el,{queue:'front'});
  new Effect.Updater(el,{newContent:ajax.responseText,queue:'end'});
  new Effect.Appear(el,{queue:'end'});
}

Is there a better way to accomplish this? If not, then I might contribute
this when I figure out how the version control system works :)


Br
Fabian

_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
_______________________________________________
Rails-spinoffs mailing list
Rails-spinoffs@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to