|
| 1 | +/*! |
| 2 | + :: MojsPlayer :: Player controls for [mojs](mojs.io). Intended to help you to craft `mojs` animation sequences. |
| 3 | + Oleg Solomka @LegoMushroom 2016 MIT |
| 4 | + 0.40.3 |
| 5 | +*/ |
| 6 | + |
1 | 7 | /******/ (function(modules) { // webpackBootstrap |
2 | 8 | /******/ // The module cache |
3 | 9 | /******/ var installedModules = {}; |
|
153 | 159 | this._defaults.isHidden = false; |
154 | 160 |
|
155 | 161 | var str = 'mojs-player'; |
156 | | - this.revision = '0.40.1'; |
| 162 | + this.revision = '0.40.3'; |
157 | 163 | this._prefix = str + '-' + this._hashCode(str) + '-'; |
158 | 164 | this._localStorage = this._prefix + 'model'; |
159 | 165 | }; |
|
430 | 436 | // if we set a progress in the `_play` method it returns slighly |
431 | 437 | // different when piped thru tween, so add `0.01` gap to soften that |
432 | 438 | if (p < leftBound - 0.01 && p !== 0) { |
433 | | - this._sysTween.reset(); |
| 439 | + this._reset(); |
434 | 440 | requestAnimationFrame(this._play.bind(this)); |
435 | 441 | } |
436 | 442 |
|
437 | 443 | if (p >= rightBound) { |
438 | | - this._sysTween.reset(); |
| 444 | + this._reset(); |
439 | 445 | if (this._props.isRepeat) { |
440 | 446 | requestAnimationFrame(this._play.bind(this)); |
441 | 447 | } else { |
|
463 | 469 |
|
464 | 470 | this._sysTween.play(); |
465 | 471 | }; |
| 472 | + /* |
| 473 | + Method to reset sysTween and timeline. |
| 474 | + @private |
| 475 | + */ |
466 | 476 |
|
| 477 | + |
| 478 | + MojsPlayer.prototype._reset = function _reset() { |
| 479 | + this._sysTween.reset(); |
| 480 | + this.timeline.reset(); |
| 481 | + }; |
467 | 482 | /* |
468 | 483 | Method to set play button state. |
469 | 484 | @private |
|
535 | 550 |
|
536 | 551 | MojsPlayer.prototype._onStop = function _onStop() { |
537 | 552 | this._props.isPlaying = false; |
538 | | - this._sysTween.reset(); |
| 553 | + this._reset(); |
539 | 554 | }; |
540 | 555 | /* |
541 | 556 | Method that is invoked on repeat switch state change. |
|
601 | 616 |
|
602 | 617 | MojsPlayer.prototype._onProgress = function _onProgress(progress) { |
603 | 618 | this._props.progress = progress; |
604 | | - if (!this.timeline._prevTime) { |
605 | | - this.timeline.setProgress(0); |
| 619 | + // if timeline was reset - refresh it's state |
| 620 | + // by incremental updates until progress (0 always) |
| 621 | + if (!this.timeline._prevTime && progress > 0) { |
| 622 | + var start = 0, |
| 623 | + step = 0.1; |
| 624 | + do { |
| 625 | + this.timeline.setProgress(start); |
| 626 | + start += step; |
| 627 | + } while (start + step < progress); |
606 | 628 | } |
607 | 629 | this.timeline.setProgress(progress); |
608 | 630 | }; |
|
6742 | 6764 |
|
6743 | 6765 |
|
6744 | 6766 | Ripple.prototype._addRipple = function _addRipple() { |
6745 | | - var _ref; |
| 6767 | + var _this2 = this, |
| 6768 | + _ref; |
6746 | 6769 |
|
6747 | 6770 | this.transit = new mojs.Transit((_ref = { |
6748 | 6771 | parent: this.el, |
6749 | 6772 | strokeWidth: { 10: 0 }, |
6750 | 6773 | fill: 'none', |
6751 | | - // stroke: 'white', |
6752 | 6774 | stroke: 'hotpink' |
6753 | | - }, _ref['fill'] = 'hotpink', _ref.fillOpacity = .75, _ref.opacity = { .85: 0 }, _ref.radius = { 0: 40 }, _ref.isShowEnd = false, _ref.onStart = this._onStart.bind(this), _ref.onUpdate = this._onUpdate.bind(this), _ref)); |
6754 | | - }; |
6755 | | - /* |
6756 | | - Method that is invoked on ripple start. |
6757 | | - @private |
6758 | | - */ |
6759 | | - |
6760 | | - |
6761 | | - Ripple.prototype._onStart = function _onStart() { |
6762 | | - this.isStart = true; |
| 6775 | + }, _ref['fill'] = 'hotpink', _ref.fillOpacity = .75, _ref.opacity = { .85: 0 }, _ref.radius = { 0: 40 }, _ref.isShowEnd = false, _ref.onStart = function onStart() { |
| 6776 | + _this2.isStart = true; |
| 6777 | + }, _ref.onUpdate = this._onUpdate.bind(this), _ref.onComplete = function onComplete() { |
| 6778 | + _this2.isStart = false; |
| 6779 | + }, _ref)); |
6763 | 6780 | }; |
6764 | 6781 | /* |
6765 | 6782 | Method that is invoked on ripple update. |
|
6784 | 6801 |
|
6785 | 6802 |
|
6786 | 6803 | Ripple.prototype._release = function _release() { |
| 6804 | + // console.log('release'); |
6787 | 6805 | if (!this._props.withHold) { |
6788 | 6806 | return; |
6789 | 6807 | } |
|
6802 | 6820 | y = e.offsetY != null ? e.offsetY : e.layerY; |
6803 | 6821 |
|
6804 | 6822 | this.isRelease = false; |
6805 | | - this.transit.tune({ x: x, y: y }).stop().replay(); |
| 6823 | + this.transit.tune({ x: x, y: y }).replay(); |
6806 | 6824 | }; |
6807 | 6825 | /* |
6808 | 6826 | Method that should be run on touch serface cancel. |
|
0 commit comments