Показать сообщение отдельно
  #7 (permalink)  
Старый 08.06.2012, 02:01
Отправить личное сообщение для Octane Посмотреть профиль Найти все сообщения от Octane  
Регистрация: 10.07.2008
Сообщений: 3,873

Да ничего там сложного:
<!DOCTYPE html>
	<meta charset="utf-8">
		body {
			margin: 0;
		.page {
			position: relative;
		#cover {
			display: none;
			position: fixed;
			top: 0;
			right: 0;
			bottom: 0;
			left: 0;
			background: #fff;
			opacity: 0.8;
		#drag {
			position: absolute;
			top: 0;
			left: 0;
			width: 50px;
			height: 50px;
			background: #afa;
	<div class="page">
		<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
		<div id="cover"></div>
		<div id="drag"></div>
	(function () {
		var drag = document.getElementById("drag"),
			style = drag.style,
			cover = document.getElementById("cover"),
			offsetTop, offsetLeft;

		function onDrag(event) {
			style.top = event.pageY - offsetTop + "px";
			style.left = event.pageX - offsetLeft + "px";

		function onDrop() {
			cover.style.display = "none";
			document.removeEventListener("mousemove", onDrag, false);
			document.removeEventListener("mouseup", onDrop, false);
		drag.addEventListener("mousedown", function (event) {
			var rect = drag.getBoundingClientRect();
			offsetTop = event.pageY - rect.top;
			offsetLeft = event.pageX - rect.left;
			cover.style.display = "block";
			document.addEventListener("mousemove", onDrag, false);
			document.addEventListener("mouseup", onDrop, false);
		}, false);

		drag.addEventListener("dragstart", function (event) {
		}, false);


Opera как всегда круче всех

Последний раз редактировалось Octane, 13.06.2012 в 16:08. Причина: preventDefault для mousedown
Ответить с цитированием