Mirgorod
@Mirgorod

С алгоритмом размещения окон как в Visual Studio?

Здравствуйте, я пытаюсь создать такой же самый эффект размещения окон как и в Visual Studio, но в вебе.

Вот скрин того, что уже есть:



screen28.png

Я пробовал проверять пересечение окон с текущим окном, но возникают различные проблемы. Вот пример:

this.calculateWindows = function(currentWindow) {<br>
	$('.fixedWindow').each(function(index){<br>
		if ( $(currentWindow).css("left") == '0px' && $(currentWindow).css("bottom") == '0px' && ($(currentWindow).position().left < ($(this).position().left + $(this).width())) && ($(currentWindow).position().top < ($(this).position().top + $(this).height())) ) {<br>
			alert('1');<br>
			$(this).css({<br>
				'height' : ($(this).height() - $(currentWindow).height() - option.between) + 'px'<br>
			});<br>
		}<br>
		else if ( $(currentWindow).css("right") == '0px' && $(currentWindow).css("top") == '0px' && ($(currentWindow).position().left < ($(this).position().left + $(this).width())) && ($(currentWindow).position().top + $(currentWindow).height() > $(this).position().top) ) {<br>
			alert('2');<br>
			$(this).css({<br>
				'width' : ($(this).width() - $(currentWindow).width() - option.between) + 'px'<br>
			});<br>
		}<br>
		else if ( parseInt($(currentWindow).css("right")) > 0 && $(currentWindow).css("left") == '0px' && $(currentWindow).css("top") == '0px' && (($(currentWindow).position().left + $(currentWindow).width()) > $(this).position().left) && ($(currentWindow).position().top < ($(this).position().top + $(this).height())) ) {<br>
			alert('3');<br>
			$(this).css({<br>
				'width' : ($(this).width() - $(currentWindow).width() - option.between) + 'px',<br>
				'left' : ($(this).position().left + $(currentWindow).width() + option.between) + "px"<br>
			});<br>
		}<br>
		else if ( $(currentWindow).css("left") == '0px' && $(currentWindow).css("top") == '0px' && (($(currentWindow).position().left + $(currentWindow).width()) > $(this).position().left) && ($(currentWindow).position().top < ($(this).position().top + $(this).height()))) {<br>
			alert('4');<br>
			$(this).css({<br>
				'height' : ($(this).height() - $(currentWindow).height() - option.between) + 'px',<br>
				'top' : ($(this).position().top + $(currentWindow).height() + option.between) + "px"<br>
			});<br>
		}<br>
	});<br>
}




currentWindow — текущее окно (окно, которое размещал)

this — каждое фиксированное окно, кроме текущего.



Заранее спасибо за предложенные алгоритмы.



P.S.

Использую jQuery, jQuery UI.
  • Вопрос задан
  • 2467 просмотров
Пригласить эксперта
Ответы на вопрос 1
taliban
@taliban
php программист
Вот вам код что я наделал, хочу чтоб мой код работал вот так: скажите что мне делать.
Если хотите помощи, задайте вопрос правильно. Очень неинтересно копаться в чужом коде чтоб понять:
1. Чего человек хочет
2. Какие «различные проблемы» возникают
Итд.
Заведите себе обьект нечто типа:

var WindowManager = {
    windows: {
        'firstId': {'width': 100, 'height': 100, 'x': 100, 'y': 100},
        'secondId': {'width': 100, 'height': 100, 'x': 100, 'y': 100},
    },
    addWindow: function('id'){},
    checkWIndow: function(id){},
    attachWindow: function(id){},
    ...
}

В итоге логика станет понятней и короче.
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы