@@ -8,7 +8,8 @@ import { translate } from '../../services/translation.service';
88} )
99export class AppTeamLanding {
1010 // private allowWebp = localStorage.getItem('allowWebp') === 'true' ? true : false;
11-
11+ backgroundPhoto : string ;
12+ headshotPhoto : string ;
1213 @Prop ( ) match : MatchResults ;
1314 @Prop ( ) history : RouterHistory ;
1415
@@ -402,6 +403,10 @@ export class AppTeamLanding {
402403 this . changeMetadata ( ) ;
403404 }
404405
406+ componentDidUnload ( ) {
407+ window . removeEventListener ( 'resize' , this . updateBackground , false ) ;
408+ }
409+
405410 changeMetadata ( ) {
406411 if ( this . data [ this . match . params . member ] ) {
407412 // Change meta tags dynamically
@@ -421,32 +426,33 @@ export class AppTeamLanding {
421426 return img ;
422427 }
423428
429+ updateBackground ( ) {
430+ const hero = document . querySelector ( '.team-landing > .container-fluid > .hero' ) as HTMLElement ;
431+ if ( window . innerWidth > 767.98 ) {
432+ hero . style . backgroundColor = '#292A2D' ;
433+ if ( this . backgroundPhoto != null ) {
434+ hero . style . backgroundImage = `linear-gradient(90deg, #000000 20%, rgba(255, 255, 255, 0) 70%), url(${ this . backgroundPhoto } )` ;
435+ }
436+ } else {
437+ hero . style . backgroundImage = 'none' ;
438+ hero . style . backgroundColor = 'transparent' ;
439+ }
440+ }
441+
424442 render ( ) {
425- const backgroundPhoto = this . changeImageFormat ( this . data [ this . match . params . member ] . backgroundPhoto ? this . data [ this . match . params . member ] . backgroundPhoto : null ) ;
426- const headshotPhoto = this . changeImageFormat ( this . data [ this . match . params . member ] . headshotPhoto ) ;
443+ this . backgroundPhoto = this . changeImageFormat ( this . data [ this . match . params . member ] . backgroundPhoto ? this . data [ this . match . params . member ] . backgroundPhoto : null ) ;
444+ this . headshotPhoto = this . changeImageFormat ( this . data [ this . match . params . member ] . headshotPhoto ) ;
427445 let style = { } ;
428446 if ( window . innerWidth > 767.98 ) {
429- style = backgroundPhoto
447+ style = this . backgroundPhoto
430448 ? {
431- 'background-image' : `linear-gradient(90deg, #000000 20%, rgba(255, 255, 255, 0) 70%), url(${ backgroundPhoto } )` ,
449+ 'background-image' : `linear-gradient(90deg, #000000 20%, rgba(255, 255, 255, 0) 70%), url(${ this . backgroundPhoto } )` ,
432450 }
433451 : {
434452 'background-color' : '#292A2D' ,
435453 } ;
436454 }
437- window . addEventListener ( 'resize' , ( ) => {
438- const backgroundPhoto = this . changeImageFormat ( this . data [ this . match . params . member ] . backgroundPhoto ? this . data [ this . match . params . member ] . backgroundPhoto : null ) ;
439- const hero = document . querySelector ( '.team-landing > .container-fluid > .hero' ) as HTMLElement ;
440- if ( window . innerWidth > 767.98 ) {
441- hero . style . backgroundColor = '#292A2D' ;
442- if ( backgroundPhoto ) {
443- hero . style . backgroundImage = `linear-gradient(90deg, #000000 20%, rgba(255, 255, 255, 0) 70%), url(${ backgroundPhoto } )` ;
444- }
445- } else {
446- hero . style . backgroundImage = 'none' ;
447- hero . style . backgroundColor = 'transparent' ;
448- }
449- } ) ;
455+ window . addEventListener ( 'resize' , this . updateBackground ) ;
450456
451457 return (
452458 < section class = "team-landing" >
@@ -456,7 +462,7 @@ export class AppTeamLanding {
456462 < div class = "container-fluid" >
457463 < div class = "row justify-content-center align-items-center hero" style = { style } >
458464 < div class = "col-10 col-sm-12 d-block d-md-none" >
459- < app-img class = "headshot-mobile" src = { headshotPhoto } />
465+ < app-img class = "headshot-mobile" src = { this . headshotPhoto } />
460466 </ div >
461467 < div class = "col-11 col-sm-9 col-md-7 col-lg-6 align-self-start" >
462468 < div class = "header-text" >
@@ -470,7 +476,7 @@ export class AppTeamLanding {
470476 < p > { this . data [ this . match . params . member ] . headerText } </ p >
471477 </ div >
472478 </ div >
473- < div class = "col-md-4 d-none d-md-block" > { ! backgroundPhoto && < app-img class = "headshot" src = { headshotPhoto } /> } </ div >
479+ < div class = "col-md-4 d-none d-md-block" > { ! this . backgroundPhoto && < app-img class = "headshot" src = { this . headshotPhoto } /> } </ div >
474480 </ div >
475481
476482 < div class = "row align-items-center justify-content-center bio" >
0 commit comments