1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-20 21:59:42 +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('resized', this, 'onResize');
this.attachResizer();
},
willDestroyElement() {
@ -90,20 +92,38 @@ export default Component.extend(NotifierMixin, {
let l = i.left - 100;
if (l > 350) l = 350;
$("#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', () => {
interact('#doc-toc')
.draggable({
autoScroll: true,
inertia: false,
onmove: dragMoveListener,
// inertia: true,
restrict: {
// restriction: ".body",
// endOnly: true,
// elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
}
// restrict: {
// restriction: "body",
// endOnly: true,
// elementRect: { top: 0, left: 0, bottom: 1, right: 1 }
// }
})
.resizable({
// resize from all edges and corners
@ -114,9 +134,9 @@ export default Component.extend(NotifierMixin, {
// endOnly: true,
// },
// minimum size
restrictSize: {
min: { width: 250, height: 65 },
}
// restrictSize: {
// min: { width: 250, height: 65 },
// }
})
.on('resizemove', function (event) {
var target = event.target,
@ -155,7 +175,7 @@ export default Component.extend(NotifierMixin, {
}
// 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)