MediaWiki:Skin/Mauszeiger.js: Unterschied zwischen den Versionen

aus Kamelopedia, der wüsten Enzyklopädie
Zur Navigation springen Zur Suche springen
K kurz testen ... (Chrome tut nicht ganz richtig ... )
K nur noch halb so viele Mäuse, dafür aber mehr Chaos :-
 
Zeile 11: Zeile 11:
});
});
},
},
max: 200, // maximale Anzahl Mauszeiger (bei 200 ruckelt's bei mir schon ganz schön doll ...)
max: 100, // maximale Anzahl Mauszeiger (bei 200 ruckelt's bei mir schon ganz schön doll ...)
width: $( window ).width(),
width: $( window ).width(),
height: $( window ).height(),
height: $( window ).height(),
Zeile 63: Zeile 63:
$(this).css('top', "-=" + x);
$(this).css('top', "-=" + x);
break;
break;
}
var pos = $(this).offset();
if( ( pos.top <= -50 ) || ( pos.top >= mouse.height + 50 ) || ( pos.left <= -50 ) || ( pos.left >= mouse.width + 50 ) ) {
$(this).remove();
mouse.add();
}
}
});
});
Zeile 69: Zeile 74:
}
}
}
}
$(function() {
$(function() {
mouse.init();
mouse.init();
})
})

Aktuelle Version vom 30. September 2013, 14:00 Uhr

var mouse = {
    /* Achtung! Schlüsselwort "this" nur für jQuery verwenden ... gibt sonst zum Teil Komplikationen */
	init: function() {
		mouse.add();
		$('body').one('mouseover', function(event) {
			mouse.x = event.pageX;
			mouse.y = event.pageY;
			$('body').mousemove(function(event) {
				mouse.move(event.pageX, event.pageY);
			});
		});
	},
	max: 100, // maximale Anzahl Mauszeiger (bei 200 ruckelt's bei mir schon ganz schön doll ...)
	width: $( window ).width(),
	height: $( window ).height(),
	add: function() {
		var i = Math.floor(Math.random() * mouse.height);
		var j = Math.floor(Math.random() * mouse.width);
		$('body').append('<div class="mouse" style="top:0px; left;0px; margin-top:' + i + 'px; margin-left:' + j + 'px;"></div>');
		var k = $('body div.mouse').last();
		k.hide();
		k.fadeIn(5, function() {
			if($('body div.mouse').length < mouse.max) {
				mouse.add();
			}
		});
	},
	move: function(newX, newY) {
		var x = newX - mouse.x;
		var y = newY - mouse.y;
		$('body div.mouse').each(function(index) {
			switch(index % 8) {
			case 0: // alles richtigrum
				$(this).css('left', "+=" + x);
				$(this).css('top', "+=" + y);
				break;
			case 1: // links und rechts vertauscht
				$(this).css('left', "-=" + x);
				$(this).css('top', "+=" + y);
				break;
			case 2: // oben und unten vertauscht
				$(this).css('left', "+=" + x);
				$(this).css('top', "-=" + y);
				break;
			case 3: // alles vertauscht
				$(this).css('left', "-=" + x);
				$(this).css('top', "-=" + y);
				break;
			case 4: // alles richtigrum aber mit falschen Werten
				$(this).css('left', "+=" + y);
				$(this).css('top', "+=" + x);
				break;
			case 5: // links und rechts vertauscht und mit falschen Werten
				$(this).css('left', "-=" + y);
				$(this).css('top', "+=" + x);
				break;
			case 6: // oben und unten vertauscht und mit falschen Werten
				$(this).css('left', "+=" + y);
				$(this).css('top', "-=" + x);
				break;
			case 7: // alles vertauscht und mit falschen Werten
				$(this).css('left', "-=" + y);
				$(this).css('top', "-=" + x);
				break;
			}
			var pos = $(this).offset();
			if( ( pos.top <= -50 ) || ( pos.top >= mouse.height + 50 ) || ( pos.left <= -50 ) || ( pos.left >= mouse.width + 50 ) ) {
				$(this).remove();
				mouse.add();
			}
		});
		mouse.x = newX;
		mouse.y = newY;		
	}
}
 
$(function() {
	mouse.init();
})