@@ -26,7 +26,7 @@ export class WMLCarouselOneComponent {
2626 @Input ( 'props' ) props : WMLCarouselOneProps = new WMLCarouselOneProps ( )
2727 @HostBinding ( 'class' ) myClass : string = this . classPrefix ( `View` ) ;
2828 @HostBinding ( 'attr.id' ) myId ?:string
29- @ViewChild ( "slideContainer " , { read :ViewContainerRef , static :true } ) slideContainer ! :ViewContainerRef
29+ @ViewChild ( "controller " , { read :ViewContainerRef , static :true } ) controller ! :ViewContainerRef
3030 ngUnsub = new Subject < void > ( )
3131
3232 listenForUpdate = ( ) => {
@@ -47,7 +47,7 @@ export class WMLCarouselOneComponent {
4747 if ( this . props . id ) {
4848 this . myId = this . props . id
4949 }
50- this . props . slideContainerVCF = this . slideContainer
50+ this . props . controllerVCF = this . controller
5151 this . props . ngUnsub = this . ngUnsub
5252 this . props . cdref = this . cdref
5353 this . listenForUpdate ( ) . subscribe ( )
@@ -66,7 +66,7 @@ export class WMLCarouselOneProps {
6666 constructor ( props : Partial < WMLCarouselOneProps > = { } ) { }
6767
6868 // component proeprties
69- slideContainerVCF ! :ViewContainerRef
69+ controllerVCF ! :ViewContainerRef
7070 ngUnsub = new Subject < void > ( ) ;
7171 cdref ! :ChangeDetectorRef
7272 //
@@ -79,8 +79,8 @@ export class WMLCarouselOneProps {
7979
8080 slideWidth = "23%"
8181 slideHeight = "33%"
82- distanceFromCenter = "300px"
83- distanceFromTop = '63px '
82+ slideDistanceFromCenter = "300px"
83+ slideDistanceFromTop = '-53px '
8484 classPrefix = generateClassPrefix ( 'WMLCarouselOne' )
8585
8686 slideContainer = new WMLUIProperty ( {
@@ -94,7 +94,7 @@ export class WMLCarouselOneProps {
9494 type :"transition" ,
9595 class :this . classPrefix ( 'Pod1Item0' ) ,
9696 style :{
97- height :"300px " ,
97+ height :"250px " ,
9898 border :"calc(1/10.6 * 1em) solid red"
9999 } ,
100100 keyFrameStyles : {
@@ -120,7 +120,7 @@ export class WMLCarouselOneProps {
120120
121121 init = ( ) => {
122122
123-
123+ window . resizeTo ( 1520 , 364 )
124124 this . listenForSlideContainerResize ( ) . subscribe ( )
125125 }
126126
@@ -130,18 +130,37 @@ export class WMLCarouselOneProps {
130130 takeUntil ( this . ngUnsub ) ,
131131 startWith ( null ) ,
132132 tap ( ( ) => {
133- const parentElement = this . slideContainerVCF . element . nativeElement ;
133+ const parentElement = this . controllerVCF . element . nativeElement ;
134134 const parentWidth = parseFloat ( getComputedStyle ( parentElement ) . width . split ( "px" ) [ 0 ] ) ;
135135 const parentHeight = parseFloat ( getComputedStyle ( parentElement ) . height . split ( "px" ) [ 0 ] ) ;
136136
137- console . log ( parentWidth )
138- console . log ( parentHeight )
139- this . slideWidth = `${ ( parentWidth * 0.3 ) } px` ;
140- this . slideHeight = `${ ( parentHeight * 0.35 ) } px` ;
141- this . distanceFromCenter = `${ parentWidth * .42 } px` ;
142137
143- this . slideContainer . style . perspective = `${ parentWidth } px` ;
144- this . slideContainer . style . perspectiveOrigin = `50% ${ - 25 } %` ;
138+ this . slideWidth = `${ parentWidth * 0.315 } px` ;
139+ this . slideHeight = `${ parentHeight * 0.52 } px` ;
140+ this . slideDistanceFromCenter = `${ parentWidth * .42 } px` ;
141+
142+
143+ this . slideContainer . style . perspectiveOrigin = `50% ${ - 5 } %` ;
144+ // this.controller.style.transform =`rotateY(60deg)`
145+
146+ this . slideHeight = this . calculateSlideHeight ( parentWidth , parentHeight ) + "px"
147+ this . slideDistanceFromCenter = this . calculateSlideDistanceFromCenter ( parentWidth , parentHeight ) + "px"
148+ this . slideDistanceFromTop = this . calculateSlideDistanceFromTop ( parentWidth , parentHeight ) + "px"
149+
150+ // this.slideHeight ="204px"
151+ // this.slideDistanceFromCenter ="153.82446px"
152+ // this.slideDistanceFromTop ='-20.226021999999997px'
153+ // TODO pass 1536px you must increase the perspective to preserve the shape
154+ this . slideContainer . style . perspective = `1000px` ;
155+
156+ console . log ( `Slide Height ${ this . slideHeight } ` )
157+ // console.log(`Slide Width ${this.slideWidth}`)
158+ console . log ( `Slide Distance from Center ${ this . slideDistanceFromCenter } ` )
159+ console . log ( `Distance from top ${ this . slideDistanceFromTop } ` )
160+ console . warn ( `Parent Width ${ parentWidth } ` )
161+ console . warn ( `Parent Height ${ parentHeight } ` )
162+
163+
145164 this . updateSlides ( ) ;
146165 } ) ,
147166 tap ( ( ) => {
@@ -155,10 +174,37 @@ export class WMLCarouselOneProps {
155174 return 360 / this . slides . length ;
156175 }
157176
177+ calculateSlideHeight = ( parentWidth , parentHeight ) => {
178+ // Slope and intercept calculated based on the provided data points
179+ const slope = - 0.1121 ;
180+ const intercept = 241.548 ;
181+
182+ // Calculate result based on the linear relationship
183+ const result = ( parentWidth * slope ) + intercept ;
184+
185+ return result ;
186+ }
187+
188+ calculateSlideDistanceFromCenter = ( parentWidth , parentHeight ) => {
189+ const slope = 0.3887 ; // Updated slope based on linear regression
190+ const intercept = 32.88 ; // Updated intercept based on linear regression
191+ const result = ( parentWidth * slope ) + intercept ;
192+ return result ;
193+ }
194+
195+ calculateSlideDistanceFromTop = ( parentWidth , parentHeight ) => {
196+ const slopeWidth = - 0.0489 ; // Coefficient for parentWidth
197+ const slopeHeight = - 0.0173 ; // Coefficient for parentHeight
198+ const result = ( parentWidth * slopeWidth ) + ( parentHeight * slopeHeight ) ;
199+ return result ;
200+ }
201+
202+
203+
158204 updateSlides = ( ) => {
159205 this . slides = this . slides . map ( ( slide , index0 ) => {
160206 let angle = this . getAngle ( ) ;
161- slide . view . style . transform = `rotateY(${ index0 * angle } deg) translateZ(${ this . distanceFromCenter } ) translateY(- ${ this . distanceFromTop } )` ;
207+ slide . view . style . transform = `rotateY(${ index0 * angle } deg) translateZ(${ this . slideDistanceFromCenter } ) translateY(${ this . slideDistanceFromTop } )` ;
162208 slide . view . style . height = this . slideHeight ;
163209 slide . view . style . width = this . slideWidth ;
164210 return slide ;
0 commit comments