Skip to content

Instantly share code, notes, and snippets.

@Hecatoncheir
Last active January 22, 2018 14:50
Show Gist options
  • Select an option

  • Save Hecatoncheir/21f69e7c57102c41c6a5f652cdfa3564 to your computer and use it in GitHub Desktop.

Select an option

Save Hecatoncheir/21f69e7c57102c41c6a5f652cdfa3564 to your computer and use it in GitHub Desktop.
/*Split*/
#flex-split {
display: flex;
flex-direction: column;
background-color: #fffbf7;
width: 100%;
height: calc(100vh - 84px*2);
overflow: hidden;
/*<!--box-sizing: border-box;-->*/
/*<!--min-height: 10px;-->*/
/*<!--z-index: 2;-->*/
/*<!--overflow-y:visible;-->*/
}
.split-item {
flex-grow: 0;
width: 100%;
overflow-y: scroll;
overflow-x: hidden;
}
#split-divider {
width: 100%;
min-height: 10px;
max-height: 10px;
display: block;
cursor: pointer;
/*background-color: #fffbf7;*/
background-color: #e7dfd6;
margin: 10px 0;
}
#split-divider:hover {
background-color: #d3cbc2;
}
<div id="flex-split">
<!--Main view-->
<section id="main-view" class="split-item">
<div id="split-divider"></div>
<!--Additional view-->
<section id="additional-view" class="split-item">
bool dividerHandled = false;
bool dividerOnHold = false;
int mousePositionOnStart = 0;
Future<Null> prepareDividerHandler(Element divider) async {
divider.onMouseDown.listen((MouseEvent event) {
dividerOnHold = true;
mousePositionOnStart = event.screen.y;
});
divider.parent.onMouseUp.listen((MouseEvent event) {
if (dividerOnHold) dividerOnHold = false;
});
divider.parent.onMouseMove.listen((MouseEvent event) {
if (!dividerOnHold) return;
event.preventDefault();
Element mainView = divider.parent.querySelector('#main-view');
Element additionalView = divider.parent.querySelector('#additional-view');
int dif = event.screen.y - mousePositionOnStart;
mousePositionOnStart = event.screen.y;
int mainViewHeight;
try {
mainViewHeight =
int.parse(mainView.getComputedStyle().height.replaceAll('px', ''));
} catch (err) {
mainViewHeight = 0;
}
int additionalViewHeight;
try {
additionalViewHeight = int.parse(
additionalView.getComputedStyle().height.replaceAll('px', ''));
} catch (err) {
additionalViewHeight = 0;
}
mainView.style.height = "${mainViewHeight + dif}px";
additionalView.style.height = "${additionalViewHeight - dif}px";
});
dividerHandled = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment