From 8ce124f6d6c93d62ab44827c330d2ab15033b441 Mon Sep 17 00:00:00 2001 From: Khalid Ibrahim Date: Mon, 27 May 2019 13:37:02 +0800 Subject: [PATCH 1/2] fixed dragging issues --- src/windows/tracker.es6 | 3 +++ src/windows/windows.es6 | 9 +++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/windows/tracker.es6 b/src/windows/tracker.es6 index 9ed4cc4404..a26569fa9a 100644 --- a/src/windows/tracker.es6 +++ b/src/windows/tracker.es6 @@ -225,6 +225,9 @@ export const track = (options, blankWindow) => { save_states(); }); blankWindow.on('dialogextendrestore',() => { + dialog.draggable({ + containment: false, + }) state.position.offset = dialog.offset(); state.position.mode = 'normal'; save_states(); diff --git a/src/windows/windows.es6 b/src/windows/windows.es6 index 73b2839e36..71fc906a97 100644 --- a/src/windows/windows.es6 +++ b/src/windows/windows.es6 @@ -331,13 +331,18 @@ export const createBlankWindow = function($html,options) { dialog.on('dragstop', () => { const top = dialog.offset().top; const left = dialog.offset().left; + const dialogWidth = blankWindow.dialog( "option", "width" ); + const windowWidth = $(window).width(); - if (top < 0) { - dialog.animate({ top: '0px' }, 300, dialog.trigger.bind(dialog, 'animated')); + if (top < 106) { + dialog.animate({ top: '106px' }, 300, dialog.trigger.bind(dialog, 'animated')); } if (left < 0) { dialog.animate({ left: '0px' }, 300, dialog.trigger.bind(dialog, 'animated')); } + if (left + dialogWidth > windowWidth) { + dialog.animate({ left: `${windowWidth - dialogWidth - 20}px` }, 300, dialog.trigger.bind(dialog, 'animated')); + } }); if(options.destroy) { /* register for destroy event which have been patched */ From 8d7b78d466688b17694078fafbc4da8dbab57f52 Mon Sep 17 00:00:00 2001 From: Khalid Ibrahim Date: Mon, 27 May 2019 16:04:11 +0800 Subject: [PATCH 2/2] cleaner code --- src/windows/tracker.es6 | 4 +--- src/windows/windows.es6 | 11 ++++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/windows/tracker.es6 b/src/windows/tracker.es6 index a26569fa9a..904dce58f9 100644 --- a/src/windows/tracker.es6 +++ b/src/windows/tracker.es6 @@ -225,9 +225,7 @@ export const track = (options, blankWindow) => { save_states(); }); blankWindow.on('dialogextendrestore',() => { - dialog.draggable({ - containment: false, - }) + dialog.draggable({ containment: false }) state.position.offset = dialog.offset(); state.position.mode = 'normal'; save_states(); diff --git a/src/windows/windows.es6 b/src/windows/windows.es6 index 71fc906a97..e03bbaf680 100644 --- a/src/windows/windows.es6 +++ b/src/windows/windows.es6 @@ -329,19 +329,20 @@ export const createBlankWindow = function($html,options) { dialog.draggable( "option", "scroll", true ); } dialog.on('dragstop', () => { - const top = dialog.offset().top; - const left = dialog.offset().left; + const top = dialog.offset().top; + const left = dialog.offset().left; const dialogWidth = blankWindow.dialog( "option", "width" ); const windowWidth = $(window).width(); + const navHeight = $('#nav-menu .container').height(); - if (top < 106) { - dialog.animate({ top: '106px' }, 300, dialog.trigger.bind(dialog, 'animated')); + if (top < navHeight + 36) { + dialog.animate({ top: `${navHeight + 36}px` }, 300, dialog.trigger.bind(dialog, 'animated')); } if (left < 0) { dialog.animate({ left: '0px' }, 300, dialog.trigger.bind(dialog, 'animated')); } if (left + dialogWidth > windowWidth) { - dialog.animate({ left: `${windowWidth - dialogWidth - 20}px` }, 300, dialog.trigger.bind(dialog, 'animated')); + dialog.animate({ left: `${windowWidth - dialogWidth - 10}px` }, 300, dialog.trigger.bind(dialog, 'animated')); } });