|
181 | 181 | var pinOptions = mergeOptions(options.pin, globalOptions);
|
182 | 182 | animation.pin = new PinScene($this, pinOptions);
|
183 | 183 | }
|
| 184 | + if (typeof options.class != "undefined") { |
| 185 | + var classOptions = mergeOptions(options.class, globalOptions); |
| 186 | + animation.class = new ClassScene($this, classOptions); |
| 187 | + } |
184 | 188 | animations.push(animation);
|
185 | 189 | }
|
186 | 190 | return animations;
|
|
472 | 476 | this._setFrom(this._getOldValue(style));
|
473 | 477 | this._setValue(this._getNewValue(), style);
|
474 | 478 | },
|
| 479 | + _getOldValue: function() {}, |
| 480 | + _getNewValue: function() {}, |
475 | 481 | _setFrom: function(defaultValue) {
|
476 | 482 | typeof this.from != "undefined" || (this.from = defaultValue);
|
477 | 483 | }
|
|
529 | 535 | }
|
530 | 536 | });
|
531 | 537 |
|
| 538 | + function StateScene($el, options) { |
| 539 | + typeof options.triggerHook != "undefined" || (options.triggerHook = 0); |
| 540 | + Scene.call(this, $el, options); |
| 541 | + } |
| 542 | + StateScene.prototype = inherit(Scene.prototype, { |
| 543 | + _needsUpdate: function() { |
| 544 | + return (typeof this.prevState != "undefined" || this.state == Scene.STATE_DURING) && |
| 545 | + this.prevState != this.state; |
| 546 | + } |
| 547 | + }); |
| 548 | + |
| 549 | + function ClassScene($el, options) { |
| 550 | + StateScene.call(this, $el, options); |
| 551 | + } |
| 552 | + ClassScene.prototype = inherit(Scene.prototype, { |
| 553 | + _setValue: function() { |
| 554 | + this.$el[this.state == Scene.STATE_DURING ? 'addClass' : 'removeClass'](this.to); |
| 555 | + } |
| 556 | + }); |
| 557 | + |
532 | 558 | function PinScene($el, options) {
|
533 | 559 | options.to = convertToElement(options.to);
|
534 | 560 | isElement(options.to) || (options.to = $el[0]);
|
535 | 561 | typeof options.triggerHook != "undefined" || (options.triggerHook = 0);
|
536 |
| - Scene.call(this, $el, options); |
| 562 | + StateScene.call(this, $el, options); |
537 | 563 | PinScene.scenes.push(this);
|
538 | 564 | }
|
539 | 565 | PinScene.scenes = [];
|
|
545 | 571 | }
|
546 | 572 | }
|
547 | 573 | };
|
548 |
| - PinScene.prototype = inherit(Scene.prototype, { |
| 574 | + PinScene.prototype = inherit(StateScene.prototype, { |
549 | 575 | updateStart: function() {
|
550 | 576 | if (this.state != Scene.STATE_DURING) {
|
551 | 577 | Scene.prototype.updateStart.call(this);
|
552 | 578 | }
|
553 | 579 | },
|
554 |
| - _needsUpdate: function() { |
555 |
| - return (typeof this.prevState != "undefined" || this.state == Scene.STATE_DURING) && |
556 |
| - this.prevState != this.state; |
557 |
| - }, |
558 | 580 | _getOldValue: function(style) {
|
559 | 581 | var toStyle = getComputedStyle(this.to);
|
560 | 582 | return {
|
|
0 commit comments