0
我使用以下代碼來允許用戶垂直調整DIV元素的大小,但是當單擊並拖動頁面上的句柄,文本和其他元素時,用戶只需點擊並突出顯示頁面上的所有內容。有沒有辦法阻止這種情況發生,因爲這看起來很糟糕?這與Prototype.js一起使用。JavaScript拖動選擇拖動區域周圍的文本和元素
function DragCorner(container, handle) {
var container = $(container);
var handle = $(handle);
// Add property to container to store position variables
container.moveposition = {y:0};
function moveListener(event) {
// Calculate how far the mouse moved
var moved = { y:(container.moveposition.y - event.pointerY()) };
// Reset container's x/y utility property
container.moveposition = {y:event.pointerY()};
// Update container's size
var size = container.getDimensions();
container.setStyle({height: size.height + moved.y + 'px'});
}
// Listen for 'mouse down' on handle to start the move listener
handle.observe('mousedown', function(event) {
// Set starting x/y
container.moveposition = {y:event.pointerY()};
// Start listening for mouse move on body
Event.observe(document.body,'mousemove',moveListener);
});
// Listen for 'mouse up' to cancel 'move' listener
Event.observe(document.body,'mouseup', function(event) {
Event.stopObserving(document.body,'mousemove',moveListener);
console.log('stop listening');
});
}
股利是固定的,我有一個手柄DIV是附加到我拉伸div的頂部一個div。 – 2010-06-25 21:44:38