MediaWiki:Skin/Kamel:Ungott.js: Unterschied zwischen den Versionen

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
Zeile 18: Zeile 18:
 
     for ( var i = 0; i < anz_bilder; i++ ){
 
     for ( var i = 0; i < anz_bilder; i++ ){
 
         $('#content').append(anim_bilder[i]);
 
         $('#content').append(anim_bilder[i]);
         $('#content img').last().css({'position': 'absolute', 'z-index': '-1'});
+
         $('#content img').last().css({'position': 'absolute', 'z-index': '1'});
 
         var bottom = Math.round( ( ( $('#content').outerHeight() + anim_bilder[i].height ) * Math.random() ) - anim_bilder[i].height );
 
         var bottom = Math.round( ( ( $('#content').outerHeight() + anim_bilder[i].height ) * Math.random() ) - anim_bilder[i].height );
 
         var left  = Math.round( ( ( $('#content').outerWidth() + anim_bilder[i].width ) * Math.random() ) - anim_bilder[i].width );
 
         var left  = Math.round( ( ( $('#content').outerWidth() + anim_bilder[i].width ) * Math.random() ) - anim_bilder[i].width );

Version vom 25. August 2011, 22:25 Uhr

var anz_bilder  = 20;
var anim_bilder = new Array();
var bild_info = [
    { "src": "http://kamelopedia.mormo.org/images/6/6c/BunchieViola.gif",    "width": 53,  "height": 66 }
]

for ( var i = 0; i < anz_bilder; i++ ){
    var size              = Math.random() * 2;
    var src               = Math.floor(Math.random() * bild_info.length);
    anim_bilder[i]        = new Image;
    anim_bilder[i].src    = bild_info[src].src;
    anim_bilder[i].width  = bild_info[src].width * size;
    anim_bilder[i].height = bild_info[src].height * size;    
}

$(function() {
    $('#content').css({'position': 'relative', 'overflow' : 'hidden'});
    for ( var i = 0; i < anz_bilder; i++ ){
        $('#content').append(anim_bilder[i]);
        $('#content img').last().css({'position': 'absolute', 'z-index': '1'});
        var bottom = Math.round( ( ( $('#content').outerHeight() + anim_bilder[i].height ) * Math.random() ) - anim_bilder[i].height );
        var left   = Math.round( ( ( $('#content').outerWidth() + anim_bilder[i].width ) * Math.random() ) - anim_bilder[i].width );
        $('#content img').last().css('bottom', bottom + 'px');
        $('#content img').last().css('left', left + 'px');
        $('#content img').last().animate(
            { bottom: '+' + $('#content').outerHeight() }, {
            duration: Math.round(7000 * Math.random() + 7000) - bottom * 15,
            easing: 'linear',
            complete: function(){ resetimage($(this)); },
            queue: false }
        );
        swing($('#content img').last(), 
            $('#content img').last().width() / 8 + ($('#content img').last().width() / 8 * Math.random()),
            400 * Math.random() + 250);
    }
});

function resetimage(anim_bild) {
    var left   = ( ( $('#content').outerWidth() + anim_bilder[i].width ) * Math.random() ) - anim_bilder[i].width;
    anim_bild.css('left', left + 'px');   
    anim_bild.css('bottom', '-' + anim_bild.height() + 'px');
    anim_bild.animate(
        { bottom: '+' + $('#content').outerHeight() }, {
        duration: Math.round(7000 * Math.random() + 7000),
        easing: 'linear',
        complete: function(){ resetimage($(this)); },
        queue: false }
    );
}

function swing(anim_bild, amount,  duration) {
    anim_bild.animate(
        { marginLeft: amount }, {
        duration: duration,
        queue: false,
            complete: function(){ 
                $(this).animate(
                    { marginLeft: 0 }, {
                    duration: duration,
                    queue: false,
                    complete: function(){ swing($(this), amount, duration) }
                    }
                )
            }
        }
    );
}