diff --git a/src/windows/tracker.es6 b/src/windows/tracker.es6 index 9ed4cc4404..904dce58f9 100644 --- a/src/windows/tracker.es6 +++ b/src/windows/tracker.es6 @@ -225,6 +225,7 @@ 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..e03bbaf680 100644 --- a/src/windows/windows.es6 +++ b/src/windows/windows.es6 @@ -329,15 +329,21 @@ export const createBlankWindow = function($html,options) { dialog.draggable( "option", "scroll", true ); } dialog.on('dragstop', () => { - const top = dialog.offset().top; - const left = dialog.offset().left; - - if (top < 0) { - dialog.animate({ top: '0px' }, 300, dialog.trigger.bind(dialog, 'animated')); + 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 < 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 - 10}px` }, 300, dialog.trigger.bind(dialog, 'animated')); + } }); if(options.destroy) { /* register for destroy event which have been patched */