@@ -25,6 +25,7 @@ export default class PageBuilder implements PageBuilderInterface {
25
25
public loading : KnockoutObservable < boolean > = ko . observable ( true ) ;
26
26
public wrapperStyles : KnockoutObservable < { [ key : string ] : string } > = ko . observable ( { } ) ;
27
27
private previousWrapperStyles : { [ key : string ] : string } = { } ;
28
+ private previousPanelHeight : number ;
28
29
29
30
constructor ( config : any , initialValue : string ) {
30
31
Config . setConfig ( config ) ;
@@ -50,8 +51,15 @@ export default class PageBuilder implements PageBuilderInterface {
50
51
public toggleFullScreen ( ) : void {
51
52
const stageWrapper = $ ( "#" + this . stage . id ) . parent ( ) ;
52
53
const pageBuilderWrapper = stageWrapper . parents ( ".pagebuilder-wysiwyg-wrapper" ) ;
54
+ const panel = stageWrapper . find ( ".pagebuilder-panel" ) ;
53
55
if ( ! this . isFullScreen ( ) ) {
54
- pageBuilderWrapper . height ( pageBuilderWrapper . height ( ) ) ;
56
+ pageBuilderWrapper . height ( pageBuilderWrapper . outerHeight ( ) ) ;
57
+ this . previousPanelHeight = panel . outerHeight ( ) ;
58
+ panel . css ( "height" , this . previousPanelHeight + "px" ) ;
59
+ /**
60
+ * Fix the stage in the exact place it is when it's part of the content and allow it to transition to full
61
+ * screen.
62
+ */
55
63
this . previousWrapperStyles = {
56
64
'position' : 'fixed' ,
57
65
'top' : parseInt ( stageWrapper . offset ( ) . top . toString ( ) , 10 ) -
@@ -61,23 +69,31 @@ export default class PageBuilder implements PageBuilderInterface {
61
69
'width' : stageWrapper . outerWidth ( ) . toString ( ) + 'px'
62
70
} ;
63
71
this . wrapperStyles ( this . previousWrapperStyles ) ;
64
- this . isFullScreen ( ! this . isFullScreen ( ) ) ;
72
+ this . isFullScreen ( true ) ;
65
73
_ . defer ( ( ) => {
74
+ // Remove all styles we applied to fix the position once we're transitioning
75
+ panel . css ( "height" , "" ) ;
66
76
this . wrapperStyles ( Object . keys ( this . previousWrapperStyles )
67
77
. reduce ( ( object : object , styleName : string ) => {
68
78
return Object . assign ( object , { [ styleName ] : "" } ) ;
69
79
} , { } )
70
80
) ;
71
81
} ) ;
72
82
} else {
83
+ // When leaving full screen mode just transition back to the original state
73
84
this . wrapperStyles ( this . previousWrapperStyles ) ;
85
+ this . isFullScreen ( false ) ;
86
+ panel . css ( "height" , this . previousPanelHeight + "px" ) ;
87
+ // Wait for the 350ms animation to complete before changing these properties back
74
88
_ . delay ( ( ) => {
75
- this . isFullScreen ( ! this . isFullScreen ( ) ) ;
89
+ panel . css ( "height" , "" ) ;
76
90
this . wrapperStyles ( Object . keys ( this . previousWrapperStyles )
77
91
. reduce ( ( object : object , styleName : string ) => {
78
92
return Object . assign ( object , { [ styleName ] : "" } ) ;
79
93
} , { } )
80
94
) ;
95
+ this . previousWrapperStyles = { } ;
96
+ this . previousPanelHeight = null ;
81
97
} , 350 ) ;
82
98
}
83
99
}
0 commit comments