Bu daha önce sorulmuş ve kodumu çalıştırdım.JS/Jquery Tanrının rasgele konumu
Sorun, bazı tuhaf görünümlerde, komut dosyasının donma gibi görünüyor. Yapabileceğin bir şey yok ama sekmeyi öldür.
Donmuşsa döngüyü sonlandıracak bir yedekleme komut dosyası oluşturmaya çalıştım, ancak bu iş bitmiş gibi görünmüyor.
Bana neyin yanlış olduğunu söyleyen var mı? Ya da genel olarak senaryodaki bir hatayı, donmaya neden olan şeyleri göster? sitede Thats
kod çalıştıran burada: http://unkn0wn3d.comJS Kod eithere vardır: Burada http://unkn0wn3d.com/css/pos.js
ya:
var pos = function(){
var containerW = $("article").width();
var containerH = $("article").height();
var langH = parseInt($(".languages").position().top + $(".languages").height());
var langW = parseInt($(".languages").position().left + $(".languages").width());
var creditW = parseInt($(".credit").position().left - $(".link:first").width() + 15);
var positions = [];
var froze = false;
setTimeout(function(){froze=true;}, 2000)
$('.link').each(function() {
var coords = {
w: $(this).outerWidth(true)+5,
h: $(this).outerHeight(true)+5
};
var success = false;
while (!success)
{
coords.x = parseInt(Math.random() * (containerW-coords.w));
coords.y = parseInt(Math.random() * (containerH-coords.h));
var success = true;
$.each(positions, function(){
if (froze){return false;}
if (
(coords.x <= langW &&
coords.y <= langH) ||
(coords.x >= creditW &&
coords.y <= langH) ||
(coords.x <= (this.x + this.w) &&
(coords.x + coords.w) >= this.x &&
coords.y <= (this.y + this.h) &&
(coords.y + coords.h) >= this.y)
)
{
success = false;
}
});
}
positions.push(coords);
$(this).css({
top: coords.y + 'px',
left: coords.x + 'px',
display: 'block'
});
})};
var waitForFinalEvent = (function() {
var timers = {};
return function (callback, ms, uniqueId) {
if (!uniqueId) {
uniqueId = "Don't call this twice without a uniqueId";
}
if (timers[uniqueId]) {
clearTimeout (timers[uniqueId]);
}
timers[uniqueId] = setTimeout(callback, ms);
};
})();
$(document).ready(
pos()
);
$(window).resize(function() {
waitForFinalEvent(function(){pos();}, 500, "resize");
});
Bu harika! Yayınların büyüklüğü, portre cihazlarının büyük yayınlar almamasını sağlamak için vmin tarafından kontrol edilir. İnce ve uzun bir görünüm alanı oluşturursanız, yayınların daha büyük olmayacağını fark edeceksiniz. – Unkn0wn