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.44.0
5+ */
6+
17( function webpackUniversalModuleDefinition ( root , factory ) {
28 if ( typeof exports === 'object' && typeof module === 'object' )
39 module . exports = factory ( ) ;
@@ -179,7 +185,9 @@ return /******/ (function(modules) { // webpackBootstrap
179185 this . _defaults . onSeekEnd = null ;
180186 this . _defaults . onProgress = null ;
181187
182- this . revision = '0.43.16' ;
188+ this . _play = this . _play . bind ( this ) ;
189+
190+ this . revision = '0.44.0' ;
183191
184192 var str = this . _fallbackTo ( this . _o . name , this . _defaults . name ) ;
185193 str += str === this . _defaults . name ? '' : '__' + this . _defaults . name ;
@@ -445,23 +453,26 @@ return /******/ (function(modules) { // webpackBootstrap
445453 var isUndefined = typeof add === 'undefined' ;
446454
447455 if ( ! isUndefined ) {
448- add = add . timeline || add ;
456+ add = add . timeline || add . tween || add ;
449457 }
450458
451- var isTween = add instanceof mojs . Tween ;
452- var isTimeline = add instanceof mojs . Timeline ;
459+ var isAdd = ! ! add . setProgress ;
453460
454- if ( isUndefined || ! ( isTween || isTimeline ) ) {
461+ if ( isUndefined || ! isAdd ) {
455462 throw new Error ( 'MojsPlayer expects Tween/Timeline/Module as `add` option in constructor call. [ new MojsPlayer({ add: new mojs.Tween }); ]' ) ;
456463 return ;
457464 }
458465
459466 this . timeline . add ( this . _o . add ) ;
460467
468+ var _props = this . timeline . _props ;
469+
470+ var duration = _props . repeatTime !== void 0 ? _props : _props . delay + _props . duration ;
471+
461472 this . _sysTween = new mojs . Tween ( {
462473 easing : 'linear.none' ,
463- duration : this . timeline . _props . repeatTime ,
464- onProgress : this . _onSysProgress . bind ( this ) ,
474+ duration : duration ,
475+ onUpdate : this . _onSysProgress . bind ( this ) ,
465476 onComplete : this . _onSysTweenComplete . bind ( this ) ,
466477 onPlaybackStop : function onPlaybackStop ( ) {
467478 _this3 . _setPlayState ( 'off' ) ;
@@ -492,18 +503,14 @@ return /******/ (function(modules) { // webpackBootstrap
492503 // different when piped thru tween, so add `0.01` gap to soften that
493504 if ( p < leftBound - 0.01 && p !== 0 ) {
494505 this . _reset ( ) ;
495- requestAnimationFrame ( this . _play . bind ( this ) ) ;
506+ requestAnimationFrame ( this . _play ) ;
496507 }
497508
498509 if ( p >= rightBound ) {
499-
500510 this . _reset ( rightBound === 1 ) ;
501511
502- // if ( rightBound === 1 ) { this._sysTween.stop( ); }
503- // else { this._reset() }
504-
505512 if ( this . _props . isRepeat ) {
506- requestAnimationFrame ( this . _play . bind ( this ) ) ;
513+ requestAnimationFrame ( this . _play ) ;
507514 } else {
508515 this . _props . isPlaying = false ;
509516 }
@@ -516,9 +523,9 @@ return /******/ (function(modules) { // webpackBootstrap
516523
517524
518525 MojsPlayer . prototype . _play = function _play ( ) {
519- var p = this . _props ,
520- leftBound = p . isBounds ? p . leftBound : p . progress ,
521- progress = p . progress >= this . _getBound ( 'right' ) ? leftBound : p . progress ;
526+ var p = this . _props ;
527+ var leftBound = p . isBounds ? p . leftBound : p . progress ;
528+ var progress = p . progress >= this . _getBound ( 'right' ) ? leftBound : p . progress ;
522529
523530 if ( progress === 1 ) {
524531 progress = p . isBounds ? p . leftBound : 0 ;
@@ -539,19 +546,18 @@ return /******/ (function(modules) { // webpackBootstrap
539546 MojsPlayer . prototype . _reset = function _reset ( isPause ) {
540547 this . _sysTween . reset ( ) ;
541548
542- if ( ! isPause ) {
543- // this.timeline.pause();
544- var p = this . _props ,
545- progress = p . progress ;
546-
547- var start = progress ,
548- leftBound = p . isBounds ? p . leftBound : 0 ;
549-
550- while ( start - p . precision >= leftBound ) {
551- start -= p . precision ;
552- this . timeline . setProgress ( start ) ;
553- }
554- }
549+ // if ( !isPause ) {
550+ // const p = this._props,
551+ // progress = p.progress;
552+ //
553+ // let start = progress,
554+ // leftBound = (p.isBounds) ? p.leftBound : 0;
555+ //
556+ // // while ( (start - p.precision) >= leftBound ) {
557+ // // start -= p.precision;
558+ // // this.timeline.setProgress( start );
559+ // // }
560+ // }
555561
556562 this . timeline . reset ( ) ;
557563 } ;
@@ -713,13 +719,14 @@ return /******/ (function(modules) { // webpackBootstrap
713719 this . _props . progress = progress ;
714720 // if timeline was reset - refresh it's state
715721 // by incremental updates until progress (0 always)
716- if ( ! this . timeline . _prevTime && progress > 0 ) {
717- var start = 0 ;
718- do {
719- this . timeline . setProgress ( start ) ;
720- start += this . _props . precision ;
721- } while ( start + this . _props . precision < progress ) ;
722- }
722+ // if ( !this.timeline._prevTime && progress > 0 ) {
723+ // let start = 0;
724+ // do {
725+ // this.timeline.setProgress( start );
726+ // start += this._props.precision;
727+ // } while ( start + this._props.precision < progress );
728+ // }
729+ // console.log(`timeline.setProgress: ${progress}`);
723730 this . timeline . setProgress ( progress ) ;
724731
725732 var onProgress = this . _props . onProgress ;
@@ -3598,7 +3605,7 @@ return /******/ (function(modules) { // webpackBootstrap
35983605 minBound = p . minBound * this . _maxWidth ,
35993606 maxBound = p . maxBound * this . _maxWidth ;
36003607
3601- shift = mojs . h . clamp ( shift , minBound , maxBound ) ;
3608+ shift = this . clamp ( shift , minBound , maxBound ) ;
36023609 this . _applyShift ( shift ) ;
36033610 if ( isCallback ) {
36043611 this . _onProgress ( shift ) ;
@@ -3607,6 +3614,21 @@ return /******/ (function(modules) { // webpackBootstrap
36073614 }
36083615 return shift ;
36093616 } ;
3617+
3618+ /**
3619+ * clamp - functiboundson to clamp a `value` between `min` and `max`
3620+ *
3621+ * @param {Number } value Value to clamp.
3622+ * @param {Number } min Min bound
3623+ * @param {Number } max Max bound
3624+ * @return {Number } Clamped value.
3625+ */
3626+
3627+
3628+ Handle . prototype . clamp = function clamp ( value , min , max ) {
3629+ return Math . min ( Math . max ( value , min ) , max ) ;
3630+ } ;
3631+
36103632 /*
36113633 Method to apply shift to the DOMElement.
36123634 @private
@@ -7041,9 +7063,6 @@ return /******/ (function(modules) { // webpackBootstrap
70417063
70427064 function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
70437065
7044- // require('css/blocks/handle.postcss.css');
7045- // let CLASSES = require('css/blocks/handle.postcss.css.json');
7046-
70477066 var Ripple = function ( _Module ) {
70487067 ( 0 , _inherits3 . default ) ( Ripple , _Module ) ;
70497068
@@ -7082,7 +7101,9 @@ return /******/ (function(modules) { // webpackBootstrap
70827101
70837102 this . el . appendChild ( this . curtain ) ;
70847103
7085- this . _addRipple ( ) ;
7104+ if ( mojs . Shape ) {
7105+ this . _addRipple ( ) ;
7106+ }
70867107 } ;
70877108 /*
70887109 Method to construct ripple object.
@@ -7120,7 +7141,10 @@ return /******/ (function(modules) { // webpackBootstrap
71207141 }
71217142 if ( p >= .15 && this . isStart && ! this . isRelease ) {
71227143 this . isStart = false ;
7123- this . shape . setSpeed ( .02 ) ;
7144+
7145+ if ( mojs . Shape ) {
7146+ this . shape . setSpeed ( .02 ) ;
7147+ }
71247148 }
71257149 } ;
71267150 /*
@@ -7134,7 +7158,10 @@ return /******/ (function(modules) { // webpackBootstrap
71347158 return ;
71357159 }
71367160 this . isRelease = true ;
7137- this . shape . setSpeed ( 1 ) . play ( ) ;
7161+
7162+ if ( mojs . Shape ) {
7163+ this . shape . setSpeed ( 1 ) . play ( ) ;
7164+ }
71387165 } ;
71397166 /*
71407167 Method that should be run on touch serface hold.
@@ -7148,7 +7175,9 @@ return /******/ (function(modules) { // webpackBootstrap
71487175 y = e . offsetY != null ? e . offsetY : e . layerY ;
71497176
71507177 this . isRelease = false ;
7151- this . shape . tune ( { x : x , y : y } ) . replay ( ) ;
7178+ if ( mojs . Shape ) {
7179+ this . shape . tune ( { x : x , y : y } ) . replay ( ) ;
7180+ }
71527181 } ;
71537182 /*
71547183 Method that should be run on touch serface cancel.
@@ -7161,7 +7190,10 @@ return /******/ (function(modules) { // webpackBootstrap
71617190 return ;
71627191 }
71637192 this . isRelease = true ;
7164- this . shape . pause ( ) . setSpeed ( 1 ) . playBackward ( ) ;
7193+
7194+ if ( mojs . Shape ) {
7195+ this . shape . pause ( ) . setSpeed ( 1 ) . playBackward ( ) ;
7196+ }
71657197 } ;
71667198
71677199 return Ripple ;
@@ -8443,7 +8475,7 @@ return /******/ (function(modules) { // webpackBootstrap
84438475
84448476
84458477 // module
8446- exports . push ( [ module . id , "/*$PX: 1/16rem;*/\n\n._speed-control_1mxm4_4 {\n position: relative;\n display: inline-block;\n height: 40px\n}\n\n._speed-control__slider_1mxm4_1 {\n position: absolute;\n bottom: 100%;\n left: 3px;\n width: 30px;\n height: 120px;\n padding-top: 20px;\n padding-bottom: 20px;\n border-top-right-radius: 3px;\n border-top-left-radius: 3px;\n background: #3A0839;\n -webkit-transform: translate(-99999999px, -99999999px);\n transform: translate(-99999999px, -99999999px);\n -webkit-backface-visibility: hidden;\n backface-visibility: hidden\n}\n\n._speed-control__slider_1mxm4_1:before, ._speed-control__slider_1mxm4_1:after {\n content: '';\n position: absolute;\n top: 50%;\n width: 3px;\n height: 1px;\n background: #FFF\n}\n\n._speed-control__slider_1mxm4_1:before {\n left: 5px\n}\n\n._speed-control__slider_1mxm4_1:after {\n right: 5px\n}\n\n._speed-control__button_1mxm4_1 {\n border: 1px solid cyan\n}\n\n._speed-control_1mxm4_4._is-on_1mxm4_49 ._speed-control__slider_1mxm4_1 {\n -webkit-transform: translate(0, 0);\n transform: translate(0, 0)\n}\n" , "" ] ) ;
8478+ exports . push ( [ module . id , "/*$PX: 1/16rem;*/\n\n._speed-control_1jd3z_3 {\n position: relative;\n display: inline-block;\n height: 40px\n}\n\n._speed-control__slider_1jd3z_1 {\n position: absolute;\n bottom: 100%;\n left: 3px;\n width: 30px;\n height: 120px;\n padding-top: 20px;\n padding-bottom: 20px;\n border-top-right-radius: 3px;\n border-top-left-radius: 3px;\n background: #3A0839;\n -webkit-transform: translate(-99999999px, -99999999px);\n transform: translate(-99999999px, -99999999px);\n -webkit-backface-visibility: hidden;\n backface-visibility: hidden\n}\n\n._speed-control__slider_1jd3z_1:before, ._speed-control__slider_1jd3z_1:after {\n content: '';\n position: absolute;\n top: 50%;\n width: 3px;\n height: 1px;\n background: #FFF\n}\n\n._speed-control__slider_1jd3z_1:before {\n left: 5px\n}\n\n._speed-control__slider_1jd3z_1:after {\n right: 5px\n}\n\n._speed-control__button_1jd3z_1 {\n border: 1px solid cyan\n}\n\n._speed-control_1jd3z_3._is-on_1jd3z_48 ._speed-control__slider_1jd3z_1 {\n -webkit-transform: translate(0, 0);\n transform: translate(0, 0)\n}\n" , "" ] ) ;
84478479
84488480 // exports
84498481
@@ -8453,10 +8485,10 @@ return /******/ (function(modules) { // webpackBootstrap
84538485/***/ function ( module , exports ) {
84548486
84558487 module . exports = {
8456- "speed-control" : "_speed-control_1mxm4_4 " ,
8457- "speed-control__slider" : "_speed-control__slider_1mxm4_1 " ,
8458- "speed-control__button" : "_speed-control__button_1mxm4_1 " ,
8459- "is-on" : "_is-on_1mxm4_49 "
8488+ "speed-control" : "_speed-control_1jd3z_3 " ,
8489+ "speed-control__slider" : "_speed-control__slider_1jd3z_1 " ,
8490+ "speed-control__button" : "_speed-control__button_1jd3z_1 " ,
8491+ "is-on" : "_is-on_1jd3z_48 "
84608492 } ;
84618493
84628494/***/ } ,
0 commit comments