@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- import React , { createRef } from "react" ;
17+ import React from "react" ;
1818import "context-filter-polyfill" ;
1919
2020import UIStore from "../../stores/UIStore" ;
@@ -31,24 +31,15 @@ interface IState {
3131}
3232
3333export default class BackdropPanel extends React . PureComponent < IProps , IState > {
34- private sizes = {
35- leftLeftPanelWidth : 0 ,
36- leftPanelWidth : 0 ,
37- height : 0 ,
38- } ;
3934 private style = getComputedStyle ( document . documentElement ) ;
4035
4136 public state : IState = { } ;
4237
4338 public componentDidMount ( ) {
44- UIStore . instance . on ( "SpacePanel" , this . onResize ) ;
45- UIStore . instance . on ( "GroupFilterPanelContainer" , this . onResize ) ;
4639 this . onResize ( ) ;
4740 }
4841
4942 public componentWillUnmount ( ) {
50- UIStore . instance . off ( "SpacePanel" , this . onResize ) ;
51- UIStore . instance . on ( "GroupFilterPanelContainer" , this . onResize ) ;
5243 }
5344
5445 public componentDidUpdate ( prevProps : IProps ) {
@@ -73,76 +64,37 @@ export default class BackdropPanel extends React.PureComponent<IProps, IState> {
7364 } ;
7465
7566 private refreshBackdropImage = ( ) : void => {
76- const leftLeftPanelCanvas = document . createElement ( 'canvas' ) ;
7767 const leftPanelCanvas = document . createElement ( 'canvas' ) ;
78- const leftLeftPanelContext = leftLeftPanelCanvas . getContext ( "2d" ) ;
7968 const leftPanelContext = leftPanelCanvas . getContext ( "2d" ) ;
8069 const { backgroundImage } = this . props ;
81- const { leftLeftPanelWidth, leftPanelWidth, height } = this . sizes ;
82- const width = leftLeftPanelWidth + leftPanelWidth ;
8370
8471 const imageWidth = ( backgroundImage as ImageBitmap ) . width ;
8572 const imageHeight = ( backgroundImage as ImageBitmap ) . height ;
8673
87- const contentRatio = imageWidth / imageHeight ;
88- const containerRatio = width / height ;
89- let resultHeight ;
90- let resultWidth ;
91- if ( contentRatio > containerRatio ) {
92- resultHeight = height ;
93- resultWidth = height * contentRatio ;
94- } else {
95- resultWidth = width ;
96- resultHeight = width / contentRatio ;
97- }
98-
99- // This value has been chosen to be as close with rendering as the css-only
100- // backdrop-filter: blur effect was, mostly takes effect for vertical pictures.
101- const x = width * 0.1 ;
102- const y = ( height - resultHeight ) / 2 ;
103-
104- leftLeftPanelCanvas . width = leftLeftPanelWidth ;
105- leftLeftPanelCanvas . height = height ;
10674 leftPanelCanvas . width = window . screen . width * 0.5 ;
107- leftPanelCanvas . height = height ;
75+ leftPanelCanvas . height = window . screen . height ;
10876
109- const spacesBlur = this . style . getPropertyValue ( '--llp-background-blur' ) ;
11077 const roomListBlur = this . style . getPropertyValue ( '--lp-background-blur' ) ;
11178
112- leftLeftPanelContext . filter = `blur(${ spacesBlur } )` ;
11379 leftPanelContext . filter = `blur(${ roomListBlur } )` ;
114- leftLeftPanelContext . drawImage (
115- backgroundImage ,
116- 0 , 0 ,
117- imageWidth , imageHeight ,
118- x ,
119- y ,
120- resultWidth ,
121- resultHeight ,
122- ) ;
12380 leftPanelContext . drawImage (
12481 backgroundImage ,
12582 0 , 0 ,
12683 imageWidth , imageHeight ,
127- x - leftLeftPanelWidth ,
128- y ,
129- resultWidth ,
130- resultHeight ,
84+ 0 ,
85+ 0 ,
86+ window . screen . width * 0.5 ,
87+ window . screen . height ,
13188 ) ;
13289 this . setState ( {
13390 lpImage : leftPanelCanvas . toDataURL ( 'image/jpeg' , 1 ) ,
134- llpImage : leftLeftPanelCanvas . toDataURL ( 'image/jpeg' , 1 ) ,
13591
13692 } ) ;
13793 } ;
13894
13995 public render ( ) {
14096 if ( ! this . props . backgroundImage ) return null ;
14197 return < div className = "mx_BackdropPanel" >
142- { this . state ?. llpImage !== 'data:,' && < img
143- className = "mx_BackdropPanel--canvas"
144- src = { this . state . llpImage } /> }
145-
14698 { this . state ?. lpImage !== 'data:,' && < img
14799 className = "mx_BackdropPanel--canvas"
148100 src = { this . state . lpImage } /> }
0 commit comments