1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-21 22:29:41 +02:00

improved TOC resizer logic

This commit is contained in:
Harvey Kandola 2017-12-14 19:10:26 +00:00
parent c449bdcd16
commit 26243a5a55
4 changed files with 42 additions and 26 deletions

View file

@ -53,6 +53,8 @@ export default Component.extend(NotifierMixin, {
this.eventBus.subscribe('documentPageAdded', this, 'onDocumentPageAdded'); this.eventBus.subscribe('documentPageAdded', this, 'onDocumentPageAdded');
this.eventBus.subscribe('resized', this, 'onResize'); this.eventBus.subscribe('resized', this, 'onResize');
this.attachResizer();
}, },
willDestroyElement() { willDestroyElement() {
@ -90,20 +92,38 @@ export default Component.extend(NotifierMixin, {
let l = i.left - 100; let l = i.left - 100;
if (l > 350) l = 350; if (l > 350) l = 350;
$("#doc-toc").width(l); $("#doc-toc").width(l);
}
}
$("#doc-toc").css({
'display': 'inline-block',
'position': 'fixed',
'width': l+'px',
'height': 'auto',
'transform': '',
});
}
} else {
$("#doc-toc").css({
'display': 'block',
'position': 'relative',
'width': '100%',
'height': '500px',
'transform': 'none',
});
}
},
attachResizer() {
schedule('afterRender', () => { schedule('afterRender', () => {
interact('#doc-toc') interact('#doc-toc')
.draggable({ .draggable({
autoScroll: true, autoScroll: true,
inertia: false,
onmove: dragMoveListener, onmove: dragMoveListener,
// inertia: true, // restrict: {
restrict: { // restriction: "body",
// restriction: ".body", // endOnly: true,
// endOnly: true, // elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
// elementRect: { top: 0, left: 0, bottom: 1, right: 1 } // }
}
}) })
.resizable({ .resizable({
// resize from all edges and corners // resize from all edges and corners
@ -114,9 +134,9 @@ export default Component.extend(NotifierMixin, {
// endOnly: true, // endOnly: true,
// }, // },
// minimum size // minimum size
restrictSize: { // restrictSize: {
min: { width: 250, height: 65 }, // min: { width: 250, height: 65 },
} // }
}) })
.on('resizemove', function (event) { .on('resizemove', function (event) {
var target = event.target, var target = event.target,
@ -155,7 +175,7 @@ export default Component.extend(NotifierMixin, {
} }
// this is used later in the resizing and gesture demos // this is used later in the resizing and gesture demos
window.dragMoveListener = dragMoveListener; // window.dragMoveListener = dragMoveListener;
}, },
// Controls what user can do with the toc (left sidebar) // Controls what user can do with the toc (left sidebar)

View file

@ -8,6 +8,11 @@
overflow: scroll; overflow: scroll;
box-sizing: border-box; // ensures width/height properties (and min/max properties) includes content, padding and border box-sizing: border-box; // ensures width/height properties (and min/max properties) includes content, padding and border
z-index: 777; z-index: 777;
display: block;
position: relative; //
width: 100%; //
height: 500px;
transform: none; //
> .header { > .header {
@include sticky(); @include sticky();
@ -87,12 +92,3 @@
-webkit-transform: translate(0px, 0px); -webkit-transform: translate(0px, 0px);
transform: translate(0px, 0px); transform: translate(0px, 0px);
} }
.document-toc-small {
display: inline-block;
position: relative !important;
margin: 0;
width: 100% !important;
height: 500px;
transform: none !important;
}

View file

@ -1,4 +1,4 @@
<div id="doc-toc" class="document-toc {{if isDesktop 'document-toc-desktop' 'document-toc-small'}}"> <div id="doc-toc" class="document-toc {{if isDesktop 'document-toc-desktop'}}">
<div class="header"> <div class="header">
<div class="title">Table of contents</div> <div class="title">Table of contents</div>
{{#if session.authenticated}} {{#if session.authenticated}}

File diff suppressed because one or more lines are too long