Skip to content

Commit

Permalink
run all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
legomushroom committed Apr 14, 2016
1 parent 5f01b1b commit 43dc1e5
Show file tree
Hide file tree
Showing 11 changed files with 110 additions and 54 deletions.
8 changes: 4 additions & 4 deletions karma.conf.js
Expand Up @@ -113,8 +113,8 @@ module.exports = function(config) {

// 'build/spriter.js',
// 'spec/spriter.js',
'build/stagger.js',
'spec/stagger.js',
// 'build/stagger.js',
// 'spec/stagger.js',

// 'build/easing/easing.js',
// 'spec/easing/easing.js',
Expand All @@ -126,8 +126,8 @@ module.exports = function(config) {
// 'build/tween/tweener.js',
// 'spec/tween/tweener.js',

'build/motion-path.js',
'spec/motion-path.js',
// 'build/motion-path.js',
// 'spec/motion-path.js',
// 'build/bits/*.js',
// 'spec/bits/*.js'
],
Expand Down
6 changes: 6 additions & 0 deletions lib/module.js
Expand Up @@ -42,7 +42,13 @@ var Module = (function () {

this._declareDefaults();
this._extendDefaults();

this._vars();
// COVER
// if ( this._vars() ) {
// this._o.isIt && console.log('RETURN');
// return ;
// };
this._render();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/mojs.js
Expand Up @@ -69,7 +69,7 @@ var _easingEasing = require('./easing/easing');
var _easingEasing2 = _interopRequireDefault(_easingEasing);

window.mojs = {
revision: '0.223.3', isDebug: true, helpers: _h2['default'],
revision: '0.225.2', isDebug: true, helpers: _h2['default'],
Transit: _transit2['default'], Swirl: _swirl2['default'], Burst: _burst2['default'], stagger: _stagger2['default'], Spriter: _spriter2['default'], MotionPath: _motionPath2['default'],
Tween: _tweenTween2['default'], Timeline: _tweenTimeline2['default'], Tweenable: _tweenTweenable2['default'], Thenable: _thenable2['default'], Tunable: _tunable2['default'], Module: _module3['default'],
tweener: _tweenTweener3['default'], easing: _easingEasing2['default'], shapesMap: _shapesShapesMap2['default']
Expand Down
4 changes: 3 additions & 1 deletion lib/shapes/bit.js
Expand Up @@ -60,6 +60,8 @@ var Bit = (function (_Module) {
};
this._drawMap = ['stroke', 'stroke-width', 'stroke-opacity', 'stroke-dasharray', 'fill', 'stroke-dashoffset', 'stroke-linecap', 'fill-opacity', 'transform'];
}

//
}, {
key: '_vars',
value: function _vars() {
Expand All @@ -68,7 +70,7 @@ var Bit = (function (_Module) {
} else if (!this._o.el) {
_h2['default'].error('You should pass a real context(ctx) to the bit');
// # --> COVER return if not ctx and not el
// # return true
return true;
}
this._state = {};this._drawMapLength = this._drawMap.length;
// this.calcTransform();
Expand Down
3 changes: 2 additions & 1 deletion lib/swirl.js
Expand Up @@ -214,7 +214,8 @@ var Swirl = (function (_Transit) {
key: '_draw',
value: function _draw() {
// call _draw or just _drawEl @ Transit depending if there is `shape`
_transit2['default'].prototype[this._props.isWithShape ? '_draw' : '_drawEl']();
var methodName = this._props.isWithShape ? '_draw' : '_drawEl';
_transit2['default'].prototype[methodName].call(this);
}
}]);

Expand Down
67 changes: 47 additions & 20 deletions lib/tween/tween.js
Expand Up @@ -7,7 +7,7 @@ Object.defineProperty(exports, '__esModule', {

var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();

var _get = function get(_x7, _x8, _x9) { var _again = true; _function: while (_again) { var object = _x7, property = _x8, receiver = _x9; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x7 = parent; _x8 = property; _x9 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };
var _get = function get(_x8, _x9, _x10) { var _again = true; _function: while (_again) { var object = _x8, property = _x9, receiver = _x10; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x8 = parent; _x9 = property; _x10 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } };

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

Expand Down Expand Up @@ -111,13 +111,11 @@ var Tween = (function (_Module) {
var shift = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];

if (this._state === 'play' && this._isRunning) {
return false;
return this;
}
this._props.isReversed = false;
this._subPlay(shift, 'play');
this._setPlaybackState('play');
// call onPlaybackStart callback
this._playbackStart();
return this;
}

Expand All @@ -133,13 +131,11 @@ var Tween = (function (_Module) {
var shift = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];

if (this._state === 'reverse' && this._isRunning) {
return false;
return this;
}
this._props.isReversed = true;
this._subPlay(shift, 'reverse');
this._setPlaybackState('reverse');
// call onPlaybackStart callback
this._playbackStart();
return this;
}

Expand All @@ -152,12 +148,10 @@ var Tween = (function (_Module) {
key: 'pause',
value: function pause() {
if (this._state === 'pause' || this._state === 'stop') {
return false;
return this;
}
this._removeFromTweener();
this._setPlaybackState('pause');
// call onPlaybackStart callback
this._playbackPause();
return this;
}

Expand All @@ -171,7 +165,7 @@ var Tween = (function (_Module) {
key: 'stop',
value: function stop(progress) {
if (this._state === 'stop') {
return;
return this;
}
this._props.isReversed = false;
this._removeFromTweener();
Expand All @@ -183,8 +177,6 @@ var Tween = (function (_Module) {

this.setProgress(stopProc);
this._setPlaybackState('stop');
// call onPlaybackStart callback
this._playbackStop();
this._prevTime = null;
return this;
}
Expand Down Expand Up @@ -222,7 +214,7 @@ var Tween = (function (_Module) {
}

/*
API method to set total progress on timeline.
API method to set progress on tween.
@public
@param {Number} Progress to set.
@returns {Object} Self.
Expand All @@ -243,6 +235,23 @@ var Tween = (function (_Module) {
return this;
}

/*
Method to set tween's speed.
@public
@param {Number} Speed value.
@returns this.
*/
}, {
key: 'setSpeed',
value: function setSpeed(speed) {
this._props.speed = speed;
// if playing - normalize _startTime and _prevTime to the current point.
if (this._state === 'play' || this._state === 'reverse') {
this._setResumeTime(this._state);
}
return this;
}

// ^ PUBLIC METHOD(S) ^
// v PRIVATE METHOD(S) v

Expand Down Expand Up @@ -278,18 +287,34 @@ var Tween = (function (_Module) {
if (isFlip) {
this._progressTime = p.repeatTime - this._progressTime;
}
// set resume time and normalize prev/start times
this._setResumeTime(state, shift);
// add self to tweener = play
_tweener2['default'].add(this);
return this;
}

/*
Method to set _resumeTime, _startTime and _prevTime.
@private
@param {String} Current state. [play, reverse]
@param {Number} Time shift. *Default* is 0.
*/
}, {
key: '_setResumeTime',
value: function _setResumeTime(state) {
var shift = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];

// get current moment as resume time
this._resumeTime = performance.now();
// set start time regarding passed `shift` and `procTime`
this._setStartTime(this._resumeTime - Math.abs(shift) - this._progressTime, false, state);
var startTime = this._resumeTime - Math.abs(shift) - this._progressTime;
this._setStartTime(startTime, false);
// if we have prevTime - we need to normalize
// it for the current resume time
if (this._prevTime != null) {
this._prevTime = state === 'play' ? this._normPrevTimeForward() : p.endTime - this._progressTime;
this._prevTime = state === 'play' ? this._normPrevTimeForward() : this._props.endTime - this._progressTime;
}
// add self to tweener = play
_tweener2['default'].add(this);
return this;
}

/*
Expand All @@ -300,7 +325,8 @@ var Tween = (function (_Module) {
}, {
key: '_normPrevTimeForward',
value: function _normPrevTimeForward() {
var p = this._props;return p.startTime + this._progressTime - p.delay;
var p = this._props;
return p.startTime + this._progressTime - p.delay;
}

/*
Expand Down Expand Up @@ -569,6 +595,7 @@ var Tween = (function (_Module) {
}

this._prevTime = time;
// console.log(this._prevTime)
return time >= p.endTime || time <= startPoint;
}

Expand Down
18 changes: 18 additions & 0 deletions lib/tween/tweenable.js
Expand Up @@ -43,6 +43,7 @@ var Tweenable = (function (_Module) {
/*
play method for the timeline.
@public
@param {Number} Time shift.
@returns this.
*/
value: function play() {
Expand All @@ -53,6 +54,7 @@ var Tweenable = (function (_Module) {
/*
playBackward method for the timeline.
@public
@param {Number} Time shift.
@returns this.
*/
}, {
Expand All @@ -77,6 +79,9 @@ var Tweenable = (function (_Module) {
/*
stop method for the timeline.
@public
@param {Number} [0...1] Progress to set on stop.
*Default* is `0` if `play`
and `1` if `playBAckward`.
@returns this.
*/
}, {
Expand Down Expand Up @@ -113,6 +118,7 @@ var Tweenable = (function (_Module) {
/*
setProgress method for the timeline.
@public
@param {Number} [0...1] Progress value.
@returns this.
*/
}, {
Expand All @@ -122,6 +128,18 @@ var Tweenable = (function (_Module) {
return this;
}

/*
setSpeed method for the timeline.
@param {Number} Speed value.
@returns this.
*/
}, {
key: 'setSpeed',
value: function setSpeed(speed) {
this.timeline.setSpeed.apply(this.timeline, arguments);
return this;
}

// ^ PUBLIC METHOD(S) ^
// v PRIVATE METHOD(S) v

Expand Down
19 changes: 10 additions & 9 deletions spec/motion-path.coffee
Expand Up @@ -336,16 +336,17 @@ describe 'MotionPath ->', ->
mp = new MotionPath
path: 'M0,100 L100,0'
el: document.createElement 'div'
isRunLess: true
isRunLess: true,
easing: 'linear.none',
onUpdate:(p, o)->
progress = p; x = o.x; y = o.y; angle = o.angle

mp.timeline.setProgress .45
mp.timeline.setProgress .5
expect(progress.toFixed(1)).toBe '0.5'
expect(x) .toBe 50
expect(y) .toBe 50
expect(angle) .toBe 0
expect(x) .toBeCloseTo 50, 5
expect(y) .toBeCloseTo 50, 5
expect(angle) .toBeCloseTo 0, 5

describe 'fill ->', ->
div = null; container = null
Expand Down Expand Up @@ -1181,8 +1182,8 @@ describe 'MotionPath ->', ->
onUpdate: ->
).then pathStart: .5, pathEnd: 1
expect(mp.timeline._timelines.length) .toBe 2
expect(mp.timeline._timelines[1].o.duration) .toBe 2000
expect(mp.timeline._timelines[1].o.onFirstUpdate).toBeDefined()
expect(mp.timeline._timelines[1]._o.duration) .toBe 2000
expect(mp.timeline._timelines[1]._o.onFirstUpdate).toBeDefined()

it 'should add isChained option to the new timeline', ->
mp = new MotionPath(
Expand All @@ -1193,7 +1194,7 @@ describe 'MotionPath ->', ->
onUpdate: ->
).then pathStart: .5, pathEnd: 1

expect(mp.timeline._timelines[1].o.isChained).toBe true
expect(mp.timeline._timelines[1]._o.isChained).toBe true

it 'should not add isChained option if delay', ->
mp = new MotionPath(
Expand All @@ -1204,7 +1205,7 @@ describe 'MotionPath ->', ->
onUpdate: ->
).then pathStart: .5, pathEnd: 1, delay: 100

expect(mp.timeline._timelines[1].o.isChained).toBe false
expect(mp.timeline._timelines[1]._o.isChained).toBe false

describe 'tuneOptions ->', ->
it 'should tune options', ->
Expand Down Expand Up @@ -1239,7 +1240,7 @@ describe 'MotionPath ->', ->
mp = new MotionPath
path: coords
el: document.createElement 'div'
type = typeof mp.timeline._timelines[0].o.onFirstUpdate
type = typeof mp.timeline._timelines[0]._o.onFirstUpdate
expect(type).toBe 'function'

describe 'isModule flag ->', ->
Expand Down

0 comments on commit 43dc1e5

Please sign in to comment.