MorphList o LavaLamp per prototype
Volevo usare il Lavalamp in uno dei nostri progetti, ma esistono due versioni una per il jQuery e una per le MooTools, peccato che io usi prototype (testato con Prototype JavaScript framework, version 1.6.0.2).
Dopo aver fatto una ricerca poco felice su un effetto simile in prototype, l’ho rifatto! Mi sembra che funzioni abbastanza bene. Comunque provatelo e ditemi se vi da dei problemi.
1 var LavaLamp = Classcreate 2 3 var actualElement = "" 4 Eventobserve$obj'mouseover'functionevent 5 // Internet Explorer 6 if eventsrcElementactualElement = eventsrcElementid 7 // Netscape and Firefox 8 else if eventtargetactualElement = eventtargetid 9 bindthis; 10 11 var myarray = ; 12 thismenu = $objthiscurrent = thismenuselect'li.current'first; 13 14 thismenuselect'li'eachfunctionitem 15 Eventobserveitem'mouseover'functioneventthisslideitemactualElementbindthis; 16 Eventobserveitem'mouseout'functioneventthisslidethiscurrentactualElementbindthis; 17 bindthis; 18 19 thismenu'<li style="display:none;" class="background"><div class="left"></div></li>' 20 thisbgitem = thismenuselect'li.background'first; 21 thissetCurrentthiscurrent; 22 23 24 25 if!thiscurrent || thiscurrent == to && act != "" return; 26 27 thisbgitemsync: truex: tooffsetLefty: 0mode: 'absolute'transition: EffectTransitionslinear 28 thisbgitemsync: truestyle: width: togetWidth+'px' 29 30 31 32 33 thisbgitemsetStyleleft: itemoffsetLeft+'px'width: itemoffsetWidth+'px'; 34 thiscurrent = item; 35 thisbgitemshow; 36 37 38 39 Eventobservewindow'load'function 40 'lavalamp' 41 ;
Usate un ul e li per il vostro menu con id lavalamp e classe lavalampfx e ricordare di dare un id ad ogni li del menu, anche un numero progressivo:
1 2 a 3 a 4 a 5 a 6 a 7
Il css:
1 2 3 4 5
Il file lava.gif è la caramella che starà intorno al menu.
Qui non si vede l’animazione ma vi assicuro che funziona con safari 4, firefox 3.5, explorer 7 (con gli altri browser non l’ho testato, ma credo funzioni!)




Se avete letto il post e vi sembra diverso… effettivamente lo è ho cambiato leggeremente il js perchè non avevo del tutto risolto problemi di flickering dello sfondo!!