@@ -72,7 +72,8 @@ export default class MDCRippleFoundation extends MDCFoundation {
72
72
this . frame_ = { width : 0 , height : 0 } ;
73
73
this . activationState_ = this . defaultActivationState_ ( ) ;
74
74
this . xfDuration_ = 0 ;
75
- this . maxRadius = 0 ;
75
+ this . initialSize_ = 0 ;
76
+ this . maxRadius_ = 0 ;
76
77
this . listenerInfos_ = [
77
78
{ activate : 'touchstart' , deactivate : 'touchend' } ,
78
79
{ activate : 'pointerdown' , deactivate : 'pointerup' } ,
@@ -99,6 +100,7 @@ export default class MDCRippleFoundation extends MDCFoundation {
99
100
left : 0 ,
100
101
top : 0 ,
101
102
} ;
103
+ this . fgScale_ = 0 ;
102
104
}
103
105
104
106
defaultActivationState_ ( ) {
@@ -193,22 +195,6 @@ export default class MDCRippleFoundation extends MDCFoundation {
193
195
194
196
animateUnboundedActivation_ ( ) {
195
197
const { FG_UNBOUNDED_ACTIVATION } = MDCRippleFoundation . cssClasses ;
196
- let startPoint ;
197
- if ( this . activationState_ . wasActivatedByPointer ) {
198
- startPoint = getNormalizedEventCoords (
199
- this . activationState_ . activationEvent , this . adapter_ . getWindowPageOffset ( ) ,
200
- this . adapter_ . computeBoundingRect ( )
201
- ) ;
202
- } else {
203
- startPoint = {
204
- left : this . frame_ . width / 2 ,
205
- top : this . frame_ . height / 2 ,
206
- } ;
207
- }
208
- const { left, top} = startPoint ;
209
- const { VAR_XF_ORIGIN_X , VAR_XF_ORIGIN_Y } = MDCRippleFoundation . strings ;
210
- this . adapter_ . updateCssVariable ( VAR_XF_ORIGIN_X , `${ left - this . unboundedCoords_ . left } px` ) ;
211
- this . adapter_ . updateCssVariable ( VAR_XF_ORIGIN_Y , `${ top - this . unboundedCoords_ . top } px` ) ;
212
198
this . adapter_ . addClass ( FG_UNBOUNDED_ACTIVATION ) ;
213
199
}
214
200
@@ -285,7 +271,8 @@ export default class MDCRippleFoundation extends MDCFoundation {
285
271
286
272
let approxCurScale = 0 ;
287
273
if ( msElapsed > FG_TRANSFORM_DELAY_MS ) {
288
- approxCurScale = Math . min ( ( msElapsed - FG_TRANSFORM_DELAY_MS ) / this . xfDuration_ , 1 ) ;
274
+ const percentComplete = Math . min ( ( msElapsed - FG_TRANSFORM_DELAY_MS ) / this . xfDuration_ , 1 ) ;
275
+ approxCurScale = percentComplete * this . fgScale_ ;
289
276
}
290
277
291
278
const transformDuration = UNBOUNDED_TRANSFORM_DURATION_MS ;
@@ -368,30 +355,37 @@ export default class MDCRippleFoundation extends MDCFoundation {
368
355
this . frame_ = this . adapter_ . computeBoundingRect ( ) ;
369
356
370
357
const maxDim = Math . max ( this . frame_ . height , this . frame_ . width ) ;
358
+ const surfaceDiameter = Math . sqrt ( Math . pow ( this . frame_ . width , 2 ) + Math . pow ( this . frame_ . height , 2 ) ) ;
371
359
372
- // Sqrt(2) * square length == diameter
373
- this . maxRadius_ = Math . sqrt ( 2 ) * maxDim / 2 ;
360
+ // 60% of the largest dimension of the surface
361
+ this . initialSize_ = maxDim * MDCRippleFoundation . numbers . INITIAL_ORIGIN_SCALE ;
362
+
363
+ // Diameter of the surface + 10px
364
+ this . maxRadius_ = surfaceDiameter + MDCRippleFoundation . numbers . PADDING ;
365
+ this . fgScale_ = this . maxRadius_ / this . initialSize_ ;
374
366
this . xfDuration_ = 1000 * Math . sqrt ( this . maxRadius_ / 1024 ) ;
375
367
this . updateLayoutCssVars_ ( ) ;
376
368
}
377
369
378
370
updateLayoutCssVars_ ( ) {
379
- const fgSize = this . maxRadius_ * 2 ;
380
371
const {
381
372
VAR_SURFACE_WIDTH , VAR_SURFACE_HEIGHT , VAR_FG_SIZE ,
382
- VAR_FG_UNBOUNDED_TRANSFORM_DURATION , VAR_LEFT , VAR_TOP ,
373
+ VAR_FG_UNBOUNDED_TRANSFORM_DURATION , VAR_LEFT , VAR_TOP , VAR_FG_SCALE ,
383
374
} = MDCRippleFoundation . strings ;
384
375
385
376
this . adapter_ . updateCssVariable ( VAR_SURFACE_WIDTH , `${ this . frame_ . width } px` ) ;
386
377
this . adapter_ . updateCssVariable ( VAR_SURFACE_HEIGHT , `${ this . frame_ . height } px` ) ;
387
- this . adapter_ . updateCssVariable ( VAR_FG_SIZE , `${ fgSize } px` ) ;
378
+ this . adapter_ . updateCssVariable ( VAR_FG_SIZE , `${ this . initialSize_ } px` ) ;
388
379
this . adapter_ . updateCssVariable ( VAR_FG_UNBOUNDED_TRANSFORM_DURATION , `${ this . xfDuration_ } ms` ) ;
380
+ this . adapter_ . updateCssVariable ( VAR_FG_SCALE , this . fgScale_ ) ;
389
381
390
382
if ( this . adapter_ . isUnbounded ( ) ) {
391
383
this . unboundedCoords_ = {
392
- left : Math . round ( - ( fgSize / 2 ) + ( this . frame_ . width / 2 ) ) ,
393
- top : Math . round ( - ( fgSize / 2 ) + ( this . frame_ . height / 2 ) ) ,
384
+ left : Math . round ( ( this . frame_ . width / 2 ) - ( this . initialSize_ / 2 ) ) ,
385
+ top : Math . round ( ( this . frame_ . height / 2 ) - ( this . initialSize_ / 2 ) ) ,
394
386
} ;
387
+
388
+
395
389
this . adapter_ . updateCssVariable ( VAR_LEFT , `${ this . unboundedCoords_ . left } px` ) ;
396
390
this . adapter_ . updateCssVariable ( VAR_TOP , `${ this . unboundedCoords_ . top } px` ) ;
397
391
}
0 commit comments