웹 UI 라이브러리인 GWC에서 제공하는 ResizablePanel 컴포넌트에 대한 예제 코드입니다.
먼저 DOM 구성은 다음과 같습니다.
GWC Library
GWC 라이브러리는 Geoservice Web Components로 웹 GIS 개발에 최적화된 Web UI를 제공합니다.
이미지 컴포넌트
버튼 컴포넌트
- 라디오
- 옵션A
- 옵션B
슬라이더
등등..
웹 소프트웨어 개발에 필요한 많은 컴포넌트들을 제공하며 사용자 경험 향상을 위해 계속 개선되고 추가됩니다.
GWC
GEOSERVICE WEB COMPONENTS
그리고 CSS 구성은 다음과 같구요.
#panel {
box-shadow: 0 0 2px rgba(0,0,0,1), 0 0 8px rgba(0,0,0,1),
0 0 10px rgba(0,0,0,1), 0 0 24px rgba(0,0,0,1);
left: calc(100% - 30em);
right: 0;
top: 0;
width: 30em;
height: 100vh;
color: white;
background: rgba(0,0,0,0.3);
}
#panel2 {
left: 300px;
top: 300px;
width: 400px;
height: 300px;
border-radius: 8px;
box-shadow: 0 0 2px white, 0 0 8px rgba(0,0,0,1),
0 0 10px rgba(0,0,0,1), 0 0 24px rgba(0,0,0,1);
background: rgba(0,0,0,0.5);
backdrop-filter: blur(4px);
display: flex;
flex-direction: column;
font-size: 1em;
color: white;
justify-content: center;
align-items: center;
}
.content {
height: 100%;
overflow: hidden;
padding: 1em 2em;
width: 100%;
line-height: 1.5em;
}
gwc-image {
width: 15em;
height: 15em;
}
.vcenter {
color: rgb(160,160,160);
display: flex;
align-items: center;
justify-content: center;
gap: 1em;
padding: 0.5em 0;
}
gwc-slider {
width: 10em;
}
js 코드는 다음과 같습니다.
window.onload = () => {
document.querySelector("gwc-button").onclick = () => {
gwcMessage("안녕하세요.");
}
panel.addEventListener("change", (event) => {
console.log(event.detail);
// event.cancel = true;
});
window.addEventListener("resize", () => {
panel.style.right = 0;
const width = panel.offsetWidth;
panel.style.left = `calc(100% - ${width}px)`;
});
GeoServiceWebComponentManager.instance.update();
};
실행 결과는 다음과 같습니다.
비디오를 지원하지 않는 웹브라우져입니다.
이 컴포넌트는 크기 제어를 제어하기 위해 다음과 같은 코드를 사용할 수 있습니다.
dlg.resizablePanel.resizableLeft = false; // 왼쪽 모서리로 크기 조정 불가능
dlg.resizablePanel.resizableRight = false; // 오른쪽 모서리로 크기 조정 불가능
dlg.resizablePanel.resizableTop = true; // 위 모서리로 크기 조정 가능
dlg.resizablePanel.resizableBottom = true; // 아래 모서리로 크기 조정 가능
이 컴포넌트는 resizing get 속성을 통해 마우스를 이용해 현재 크기 조절 중 인지를 파악할 수 있습니다.