Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var api = {}; | 5 var api = {}; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Enumeration of scene update commands. | 8 * Enumeration of scene update commands. |
| 9 * @enum {number} | 9 * @enum {number} |
| 10 * @const | 10 * @const |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 'SCALE': 3, | 326 'SCALE': 3, |
| 327 'ROTATION': 4, | 327 'ROTATION': 4, |
| 328 'OPACITY': 5 | 328 'OPACITY': 5 |
| 329 }; | 329 }; |
| 330 | 330 |
| 331 /** | 331 /** |
| 332 * Enumeration of easing type. | 332 * Enumeration of easing type. |
| 333 * @enum {number} | 333 * @enum {number} |
| 334 * @const | 334 * @const |
| 335 */ | 335 */ |
| 336 api.Easing = { | 336 api.EasingType = { |
| 337 'LINEAR': 0, | 337 'LINEAR': 0, |
| 338 'CUBICBEZIER': 1, | 338 'CUBICBEZIER': 1, |
| 339 'EASEIN': 2, | 339 'EASEIN': 2, |
| 340 'EASEOUT': 3 | 340 'EASEOUT': 3 |
| 341 }; | 341 }; |
| 342 | 342 |
| 343 /** | 343 /** |
| 344 * Abstract easing base class. | |
| 345 * @abstract | |
|
cjgrant
2017/02/16 14:51:47
Nice! I missed that @abstract exists. Could you
tiborg
2017/02/16 17:30:49
Done. Also added to fill class.
| |
| 346 */ | |
| 347 api.Easing = class { | |
| 348 constructor(type) { | |
| 349 this.type = type; | |
| 350 } | |
| 351 } | |
| 352 | |
| 353 api.LinearEasing = class extends api.Easing { | |
| 354 constructor() { | |
| 355 super(api.EasingType.LINEAR); | |
| 356 } | |
| 357 } | |
| 358 | |
| 359 api.CubicBezierEasing = class extends api.Easing { | |
| 360 constructor(p1x, p1y, p2x, p2y) { | |
|
mthiesse
2017/02/16 15:12:06
We should provide reasonable defaults for all easi
tiborg
2017/02/16 17:30:49
Makes sense. Done.
| |
| 361 super(api.EasingType.CUBICBEZIER); | |
| 362 this.p1x = p1x; | |
| 363 this.p1y = p1y; | |
| 364 this.p2x = p2x; | |
| 365 this.p2y = p2y; | |
| 366 } | |
| 367 } | |
| 368 | |
| 369 api.InEasing = class extends api.Easing { | |
| 370 constructor(pow) { | |
| 371 super(api.EasingType.EASEIN); | |
| 372 this.pow = pow; | |
| 373 } | |
| 374 } | |
| 375 | |
| 376 api.OutEasing = class extends api.Easing { | |
| 377 constructor(pow) { | |
| 378 super(api.EasingType.EASEOUT); | |
| 379 this.pow = pow; | |
| 380 } | |
| 381 } | |
| 382 | |
| 383 /** | |
| 344 * Base animation class. An animation can vary only one object property. | 384 * Base animation class. An animation can vary only one object property. |
| 345 * @struct | 385 * @struct |
| 346 */ | 386 */ |
| 347 api.Animation = class { | 387 api.Animation = class { |
| 348 constructor(elementId, durationMs) { | 388 constructor(elementId, durationMs) { |
| 349 /** @private {number} */ | 389 /** @private {number} */ |
| 350 this.id = -1; | 390 this.id = -1; |
| 351 /** @private {number} */ | 391 /** @private {number} */ |
| 352 this.meshId = elementId; | 392 this.meshId = elementId; |
| 353 /** @private {number} */ | 393 /** @private {number} */ |
| 354 this.property = -1; | 394 this.property = -1; |
| 355 /** @private {Object} */ | 395 /** @private {Object} */ |
| 356 this.to = {}; | 396 this.to = {}; |
| 357 /** @private {Object} */ | 397 /** @private {Object} */ |
| 358 this.easing = {}; | 398 this.easing = new api.LinearEasing(); |
| 359 | 399 |
| 360 // How many milliseconds in the future to start the animation. | 400 // How many milliseconds in the future to start the animation. |
| 361 /** @private {number} */ | 401 /** @private {number} */ |
| 362 this.startInMillis = 0.0; | 402 this.startInMillis = 0.0; |
| 363 | 403 |
| 364 // Duration of the animation (milliseconds). | 404 // Duration of the animation (milliseconds). |
| 365 /** @private {number} */ | 405 /** @private {number} */ |
| 366 this.durationMillis = durationMs; | 406 this.durationMillis = durationMs; |
| 367 | |
| 368 this.easing.type = api.Easing.LINEAR; | |
| 369 } | 407 } |
| 370 | 408 |
| 371 /** | 409 /** |
| 372 * Set the id of the animation. | 410 * Set the id of the animation. |
| 373 * @param {number} id | 411 * @param {number} id |
| 374 */ | 412 */ |
| 375 setId(id) { | 413 setId(id) { |
| 376 this.id = id; | 414 this.id = id; |
| 377 } | 415 } |
| 378 | 416 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 } | 467 } |
| 430 | 468 |
| 431 /** | 469 /** |
| 432 * Set the animation's final element opacity. | 470 * Set the animation's final element opacity. |
| 433 * @param {number} opacity | 471 * @param {number} opacity |
| 434 */ | 472 */ |
| 435 setOpacity(opacity) { | 473 setOpacity(opacity) { |
| 436 this.property = api.Property.OPACITY; | 474 this.property = api.Property.OPACITY; |
| 437 this.to.x = opacity; | 475 this.to.x = opacity; |
| 438 } | 476 } |
| 477 | |
| 478 /** | |
| 479 * Set the animation's easing. | |
| 480 * @param {api.Easing} easing | |
| 481 */ | |
| 482 setEasing(easing) { | |
| 483 this.easing = easing; | |
| 484 } | |
| 439 }; | 485 }; |
| 440 | 486 |
| 441 /** | 487 /** |
| 442 * Abstract class handling webui command calls from native. The UI must | 488 * Abstract class handling webui command calls from native. The UI must |
| 443 * subclass this and override the handlers. | 489 * subclass this and override the handlers. |
| 444 */ | 490 */ |
| 445 api.NativeCommandHandler = class { | 491 api.NativeCommandHandler = class { |
| 446 /** | 492 /** |
| 447 * @param {api.Mode} mode | 493 * @param {api.Mode} mode |
| 448 */ | 494 */ |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 568 if ('updateTab' in dict) { | 614 if ('updateTab' in dict) { |
| 569 this.onUpdateTab(dict['updateTabs']); | 615 this.onUpdateTab(dict['updateTabs']); |
| 570 } | 616 } |
| 571 if ('removeTab' in dict) { | 617 if ('removeTab' in dict) { |
| 572 this.onRemoveTab(dict['removeTab']); | 618 this.onRemoveTab(dict['removeTab']); |
| 573 } | 619 } |
| 574 | 620 |
| 575 this.onCommandHandlerFinished() | 621 this.onCommandHandlerFinished() |
| 576 } | 622 } |
| 577 }; | 623 }; |
| OLD | NEW |