summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-05-30 11:38:27 +0800
committerCheng-Han, Wu2016-05-30 11:38:27 +0800
commitda45b7dc10594e0197008078d9e0c0aa1eb9542f (patch)
tree1ddaa9953d8adb914a9686b7f6a85defbb404ece /public
parent16990e35a209704aa7538bb3231085c11da05b06 (diff)
Improve resize performance and fix resize syncscroll not accurate
Diffstat (limited to 'public')
-rw-r--r--public/js/index.js45
1 files changed, 34 insertions, 11 deletions
diff --git a/public/js/index.js b/public/js/index.js
index 22652d0e..1d6db920 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -803,18 +803,41 @@ function checkEditorStyle() {
// workaround editor will have wrong doc height when editor height changed
editor.setSize(null, ui.area.edit.height());
//make editor resizable
- ui.area.edit.resizable({
- handles: 'e',
- maxWidth: $(window).width() * 0.7,
- minWidth: $(window).width() * 0.2,
- resize: function (e) {
- ui.area.resize.syncToggle.stop(true, true).show();
- },
- stop: function (e) {
- lastEditorWidth = ui.area.edit.width();
- }
- });
if (!ui.area.resize.handle.length) {
+ ui.area.edit.resizable({
+ handles: 'e',
+ maxWidth: $(window).width() * 0.7,
+ minWidth: $(window).width() * 0.2,
+ create: function (e, ui) {
+ $(this).parent().on('resize', function (e) {
+ e.stopPropagation();
+ });
+ },
+ start: function (e) {
+ editor.setOption('viewportMargin', Infinity);
+ },
+ resize: function (e) {
+ ui.area.resize.syncToggle.stop(true, true).show();
+ checkTocStyle();
+ },
+ stop: function (e) {
+ lastEditorWidth = ui.area.edit.width();
+ // workaround that scroll event bindings
+ preventSyncScrollToView = 2;
+ preventSyncScrollToEdit = true;
+ editor.setOption('viewportMargin', viewportMargin);
+ if (editorHasFocus()) {
+ windowResizeInner(function () {
+ ui.area.codemirrorScroll.scroll();
+ });
+ } else {
+ windowResizeInner(function () {
+ ui.area.view.scroll();
+ });
+ }
+ checkEditorScrollbar();
+ }
+ });
ui.area.resize.handle = $('.ui-resizable-handle');
}
if (!ui.area.resize.syncToggle.length) {