How to create a divider between two divs with prototype

2 answers

This delimiter is actually a table cell contained in a table row. It supports background-colorand background-imageto give it an effect similar to what you saw in the desktop application.

, , , , :

  • mousedown , .
  • A mousemove .
  • A mouseup, , .

, , , :

var bMouseIsDown = false;
Event.observe('separator', 'mousedown', function() {
  bMouseIsDown = true;
});
Event.observe('separator', 'mouseup', function() {
  bMouseIsDown = false;
});

Event.observe('separator', 'mousemove', function(evt) {
  if(bMouseIsDown === true) {
    var iX = Event.pointerX(evt);
    var iOffsetX = iX - Position.page($('separator'))[0];
    var iWidth = $('separator').getDimensions().width;
    var iElementOffset = iWidth - iOffsetX;
    $(this).setStyle({
        left: iX - iElementOffset
    });
  }
});
+2

Prototype, Scriptaculous draggable, , DIV.

+1
source

Source: https://habr.com/ru/post/1712751/


All Articles