Нетрадицинное я бы сказал поведение курсора в Хроме
..
|
запретите выделение текста
onstartselect |
<div id="moveit" unselectable="on">move it</div>
так делал, но все равно, курсор меняется на "I" |
попробуйте так что то изменится?
<body onselectstart='event.preventDefault()'> |
..
|
..
|
Это по ходу не баг, а фича, левую кнопку зажимаешь в любом браузере и начинаешь вводить если нет текста, курсор не меняется, в хромом не так как у остальных
|
мне кажется это только недавно появилось-наверно баг
раньше вроде нормально было |
..
|
..
|
Цитата:
mouseup mousemove я на window навешиваю |
..
|
И что за поля в Хроме слева и справа?
Это наверно margin у body body {margin:0px;padding:0px;} |
Цитата:
PS: лучше последних версий хрома, браузеров не видел |
|
Ввообщем я переписал мою ф-ию
..
|
..
|
в createWindowLayer(title, content) я бы лобавил размеры и id
createWindowLayer(title, content,id,t,l,w,h){
....
a.id=id;
a.style.top=t+'px';
.....
|
http://gyazo.com/6f14b84000ff50e5f6e9b2c323bae217
var UI = {
maxZindex: 10000,
Window: function(title, data, options) {
var conf = {close: true, width: 'auto', height: 'auto', visible: true},
container = document.createElement('div'),
header = document.createElement('table'),
tr = document.createElement('tr'),
heading = document.createElement('td'),
buttons = document.createElement('td'),
content = document.createElement('div');
addEvent(header, 'mousedown', function() {
container.style.zIndex = this.maxZindex++;
});
this.show = function() {
container.style.display = 'block';
return false;
}
this.hide = function() {
container.style.display = 'none';
return false;
}
conf = extend(conf, options || {});
if (!conf.visible) {
this.hide();
}
container.className = 'ui-window-container';
header.className = 'ui-window-header';
heading.className = 'ui-window-heading';
buttons.className = 'ui-window-buttons';
heading.appendChild(document.createTextNode(title));
tr.appendChild(heading);
if (conf.close) {
var img = new Image();
img.src = '../img/close.png';
img.onclick = this.hide;
buttons.appendChild(img);
}
tr.appendChild(buttons);
header.appendChild(tr);
container.appendChild(header);
content.style.width = options.width;
content.style.height = options.height;
content.className = 'ui-window-content';
content.innerHTML = data;
container.appendChild(content);
document.body.appendChild(container);
makeMovable(container, header);
}
};
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/page.css">
<link rel="stylesheet" type="text/css" href="css/ui.css">
<script type="text/javascript" src="../js/base.js"></script>
<script type="text/javascript" src="../js/ui.js"></script>
<script type="text/javascript">
window.onload = function() {
var w = new UI.Window('Заголовок окна', '<p>Содержимое окна.</p>', {width: '10em', visible: false});
ge('clickme').onclick = w.show;
}
</script>
</head>
<body>
<div id="page">
<h1>Перетаскивание элементов</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<a id="clickme">Показать окно</a>
</div>
</body>
</html>
|
function makeMovable(a, b) {
var position = window.getComputedStyle(a).getPropertyValue('position'),
prefix, offsetX, offsetY, movable, onSelectStart, dx, dy;
if (position == 'absolute' || position == 'fixed') {
b = b || a;
prefix = position == 'fixed' ? 'client' : 'page';
offsetX = prefix + 'X';
offsetY = prefix + 'Y';
addEvent(b, 'mousedown', function(evt) {
movable = true;
// Запрещаем Хрому менять курсор при перетаскивании
onSelectStart = document.onselectstart;
document.onselectstart = function() {
return false;
}
dx = a.offsetLeft - evt[offsetX];
dy = a.offsetTop - evt[offsetY];
});
addEvent(document, 'mouseup', function() {
if (movable) {
movable = false;
document.onselectstart = onSelectStart;
}
});
addEvent(document, 'mousemove', function(evt) {
if (movable) {
// убираем выделение текста
window.getSelection().removeAllRanges();
// рассчитываем новую позицию
a.style.left = evt[offsetX] + dx + 'px';
a.style.top = evt[offsetY] + dy + 'px';
}
});
}
}
|
| Часовой пояс GMT +3, время: 19:27. |