슬라이딩 패널 구분선을 사용하여 HTML 페이지를 다른 섹션으로 분할하시겠습니까? 어떻게 이루어지나요? (Splitting HTML page into different sections using sliding panel dividers? How is it done?)


문제 설명

슬라이딩 패널 구분선을 사용하여 HTML 페이지를 다른 섹션으로 분할하시겠습니까? 어떻게 이루어지나요? (Splitting HTML page into different sections using sliding panel dividers? How is it done?)

여기와 같이 웹페이지를 여러 섹션으로 나누고 싶습니다. 이 기술의 이름과 효율적인 구현 방법을 알아내려고 합니다.

페이지는 사용자가 패널 핸들을 사용하여 다른 섹션을 확장 및 축소할 수 있는 유연성을 제공하는 여러 섹션으로 나누어져 있습니다.

나는 이것들이 일반 프레임이 아니라고 가정하고 있습니다(어쨌든 사용을 피하고 싶습니다).

jsfiddle에 있는 것 외에 튜토리얼이나 좋은 예를 아는 사람이 있습니까?


참조 솔루션

방법 1:

the idea is quite simple. you break up the screen with some elements, it does not really matter which (say divs) with a given height.

then attach a onclick event to the handle that starts the drag. what the onclick does is attach a mousemove event to the body which will resize the elements.

here is something i wrote a while back (before my jquery days), i'm sure it could be written much better, and you might find a plugin for this, i don't know of one:

function WidenHandle(widenedELement, handleElement, ondblClick, startWidth, withCoverDiv, onDrop)
{
    this.Handle = handleElement;
    this.IsClosed = false;
    this.Element = widenedELement;
    this.LastX = 0;
    this.LastY = 0;
    this.AttachedDragFunction = null;
    this.AttachedDropFunction = null;
    this.StartWidth = startWidth ? startWidth : 300;
    this.CoverDiv;
    this.OnDrop = onDrop;
    this.IsDragging = false;
    if (withCoverDiv)
    {
        var coverDiv = document.createElement("div");
        coverDiv.style.width = "2000px";
        coverDiv.style.height = "2000px";
        coverDiv.style.display = "none";
        coverDiv.style.position = "fixed";
        coverDiv.style.zIndex = "1000";
//        coverDiv.style.backgroundColor = "red";
//        coverDiv.style.opacity = "0.3";
        coverDiv.style.top = '0px';
        this.CoverDiv = coverDiv;
        document.body.appendChild(coverDiv);
    }

    if (this.Handle.addEventListener)
    {
        this.Handle.addEventListener("mousedown", function(element)
        {
            return function(event)
            {
                element.StartDragging(event);
                if (element.CoverDiv)
                    element.CoverDiv.style.display = "";
                if (event.preventDefault)
                    event.preventDefault();
          }
        } (this), true);

        this.Handle.addEventListener("dblclick", function(element)
        {
            return function(event)
            {
                element.Close(event);
                if (element.CoverDiv)
                    element.CoverDiv.style.display = "none";
                ondblClick(element);
            }
        } (this), true);
    }
    else
    {
        this.Handle.attachEvent("onmousedown", function(element)
        {
            return function(event)
            {
                element.StartDragging(event);
                if (element.CoverDiv)
                        element.CoverDiv.style.display = "";
                if (event.preventDefault)
                    event.preventDefault();
            }
        } (this));

        this.Handle.attachEvent("ondblclick", function(element)
        {
            return function(event)
            {
                element.Close(event);
                if (element.CoverDiv)
                    element.CoverDiv.style.display = "none";
                ondblClick(element);
            }
        } (this), true);
    }
}

WidenHandle.prototype.StartDragging = function(event)
{
    this.IsDragging = true;
    if (this.CoverDiv)
        this.CoverDiv.style.display = "none";
    this.ClearAttachedEvents();

    this.LastX = this.GetX(event);
    // ** attach mouse move and mouse up events to document ** //
    this.AttachedDragFunction = function(element)
    {
        return function(event)
        {
            element.OnDragging(event);
        }
    } (this);

    this.AttachedDropFunction = function(element)
    {
        return function(event)
        {
            element.OnDropping(event);
        }
    } (this);

    if (window.attachEvent) // ie
    {
        document.attachEvent('onmousemove', this.AttachedDragFunction);
        document.attachEvent('onmouseup', this.AttachedDropFunction);
    }
    else // ff
    {
        document.onmousemove = this.AttachedDragFunction;
        document.onmouseup = this.AttachedDropFunction;
    }
}
// ** for repositioning popup while dragging ** //
WidenHandle.prototype.OnDragging = function(event)
{
    clearHtmlSelection();
    this.WidenCell(event);
}

// ** for release popup movement when dropping ** //
WidenHandle.prototype.OnDropping = function(event)
{
    this.IsDragging = false;
    if (this.CoverDiv)
        this.CoverDiv.style.display = "none";

    this.ClearAttachedEvents();

    if (this.OnDrop)
        this.OnDrop();
}

WidenHandle.prototype.ClearAttachedEvents = function()
{
    // ** detach events from document ** //
    if (window.attachEvent) // ie
    {
        document.detachEvent('onmousemove', this.AttachedDragFunction);
        document.detachEvent('onmouseup', this.AttachedDropFunction);
    }
    else // ff
    {
        document.onmousemove = null;
        document.onmouseup = null;
    }
}

WidenHandle.prototype.GetX = function(event)
{
    // ** return x position of mouse ** //
    var posx = 0;

    if (!event) event = window.event;
    if (event.pageX)
    {
        posx = event.pageX;
    }
    else if (event.clientX)
    {
        posx = event.clientX;
    }

    return posx;
}

WidenHandle.prototype.WidenCell = function(event)
{
    if (!this.Element.style.width)
        this.Element.style.width = this.Element.offsetWidth ‑ 9 + "px";

    var width = parseInt(this.Element.style.width) + (this.GetX(event) ‑ this.LastX);
    if (width > 13)
        this.Element.style.width = width + "px";

    // ** remember last mouse position ** //
    this.LastX = this.GetX(event);
}

WidenHandle.prototype.Close = function(event)
{
    var width = parseInt(this.Element.style.width);
    if (width < 30)
    {
        this.IsClosed = false;
        this.Element.style.width = "";
            return;
//        width = this.StartWidth;
    }
    else
    {
        width = 14;
        this.IsClosed = true;
    }
    this.Element.style.width = width + "px";
}

function clearHtmlSelection()
{
    var sel;
    if (document.selection && document.selection.empty)
    {
        document.selection.empty();
    }
    else if (window.getSelection)
    {
        sel = window.getSelection();
        if (sel && sel.removeAllRanges) sel.removeAllRanges();
    }
}

(by sushidubDaniel)

참조 문서

  1. Splitting HTML page into different sections using sliding panel dividers? How is it done? (CC BY‑SA 3.0/4.0)

#panel #divider #html #javascript #custom-sections






관련 질문

R을 사용하여 패널 데이터의 마지막 이벤트 이후 실행 계산 (Using R to count a run since last event in panel data)

버튼을 클릭한 후 한 패널을 표시하고 동일한 프레임에서 두 번째 버튼을 클릭하면 다른 패널을 표시합니다. (show one panel after button is clicked and other panel when second button is clicked in the same frame)

외부를 클릭하면 패널을 닫아야 함(초점 상실) (Need To Close A Panel When Clicked Outside (Lost Focus))

asp.net gridview - updatepanel을 사용하여 행당 여러 줄에 바인딩된 데이터 분산 (asp.net gridview - spread bound data across multi lines per row with updatepanel)

문자를 포함하는 고유 식별자와 함께 xtreg 사용 (Using xtreg with unique identifier that includes letters)

matlab SVM은 NaN을 반환합니다. (matlab SVM returns NaN)

특정 형식의 JAVA GUI 제작에 대한 질문 (Question about making a JAVA GUI of a certain format)

슬라이딩 패널 구분선을 사용하여 HTML 페이지를 다른 섹션으로 분할하시겠습니까? 어떻게 이루어지나요? (Splitting HTML page into different sections using sliding panel dividers? How is it done?)

Swift Mac Os 응용 프로그램 - NSSavePanel이 '백그라운드 전용' 응용 프로그램에서 올바르게 작동하지 않습니다. (Swift Mac Os Application - NSSavePanel does not behave correctly with a 'background only' application)

Python 저주 update_panels() 및 Panel.move() 문제 (Python Curses update_panels() and Panel.move() issues)

stargazer를 사용하여 plm FE 회귀에서 전체 R2를 얻는 방법은 무엇입니까? (How to get between and overall R2 from plm FE regression with stargazer?)

Java, 패널용 그래픽 개체 생성 및 편집? (Java, create and edit a Graphics Object for Panel?)







코멘트