Ever wanted to know how to get that nice, smooth scale effect on dialog boxes & other elements. Well, look no further. Bubble is my second prototype.js based effect.
What’s in the ‘zip’ file:
bubble.js
bubble.htm [example usage]
Please feel free, to download the class & use it in your own code.
bubble.js
Bubble = Class.create(Abstract, { initialize: function (id,x,y,options) { this.id = id; this.x = x; this.y = y; this.options = Object.extend({ auto: true, frequency: 5, duration: 0.4, scaleFrom: 0, scaleFromCenter: true, delay: 0.2, bduration: 1.1 }, options || {}); if (this.options.auto) { this.start(); } }, start: function () { var opt = Object.clone(this.options); var id = this.id; $(this.id).setStyle({left:this.x + 'px',top:this.y + 'px'}); new Effect.Scale(this.id,100, Object.extend({ beforeStart:function(effect){ $(effect.element).style.display = 'block'; $(effect.element).setOpacity(0); $$('#' + id + ' p').each(function(p){p.hide()}); }, afterUpdate:function(effect){ $(effect.element).setOpacity(effect.position); }, scaleFrom:opt.scaleFrom, scaleFromCenter:opt.scaleFromCenter, afterFinish:function(effect){ $$('#' + id + ' p').each(function(p){ new Effect.Appear(p,{duration:opt.duration}); }); } },{delay:opt.delay,duration:opt.bduration})); } });














