Skip to content

Commit

Permalink
burst/transit: fix callbacks context
Browse files Browse the repository at this point in the history
  • Loading branch information
legomushroom committed Apr 6, 2016
1 parent 7b505d0 commit 324f53a
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mojs",
"description": "motion graphics toolbelt for the web",
"version": "0.214.8",
"version": "0.214.9",
"license": "MIT",
"homepage": "https://github.com/legomushroom/mojs",
"authors": [
Expand Down
13 changes: 10 additions & 3 deletions build/mo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3821,7 +3821,7 @@
// reset isShowEnd flag for the submodules
obj.isShowEnd = false;
// set the submodule callbacks context
obj.callbacksContext = this;
obj.callbacksContext = this._props.callbacksContext;
return obj;
}
/*
Expand Down Expand Up @@ -8016,15 +8016,14 @@
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

window.mojs = {
revision: '0.214.8', isDebug: true, helpers: _h2.default,
revision: '0.214.9', isDebug: true, helpers: _h2.default,
Transit: _transit2.default, Swirl: _swirl2.default, Burst: _burst2.default, stagger: _stagger2.default, Spriter: _spriter2.default, MotionPath: _motionPath2.default,
Tween: _tween2.default, Timeline: _timeline2.default, Tweenable: _tweenable2.default, Thenable: _thenable2.default, Tunable: _tunable2.default, Module: _module2.default,
tweener: _tweener2.default, easing: _easing2.default, shapesMap: _shapesMap2.default
};

// TODO:
/*
callbacksContext for the swirl in burst
show/hide prev module in then chains (Transit)
add onPlaybackStart, onPlaybackStop,
onPlaybackFinish methods to support mojs-player
Expand All @@ -8040,6 +8039,14 @@
mojs.h = mojs.helpers;
mojs.delta = mojs.h.delta;

// var playEl = document.querySelector('#js-play'),
// rangeSliderEl = document.querySelector('#js-range-slider');
// document.body.addEventListener('click', function (e) {
// sw
// .tune({ timeline: {delay: 0 , repeat: 2 } })
// .replay();
// });

// ### istanbul ignore next ###
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () {
Expand Down
6 changes: 3 additions & 3 deletions build/mo.min.js

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions js/mojs.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ import tweener from './tween/tweener';
import easing from './easing/easing';

window.mojs = {
revision: '0.214.8', isDebug: true, helpers: h,
revision: '0.214.9', isDebug: true, helpers: h,
Transit, Swirl, Burst, stagger, Spriter, MotionPath,
Tween, Timeline, Tweenable, Thenable, Tunable, Module,
tweener, easing, shapesMap
}

// TODO:
/*
callbacksContext for the swirl in burst
show/hide prev module in then chains (Transit)
add onPlaybackStart, onPlaybackStop,
onPlaybackFinish methods to support mojs-player
Expand All @@ -41,6 +40,14 @@ window.mojs = {
mojs.h = mojs.helpers;
mojs.delta = mojs.h.delta;

// var playEl = document.querySelector('#js-play'),
// rangeSliderEl = document.querySelector('#js-range-slider');
// document.body.addEventListener('click', function (e) {
// sw
// .tune({ timeline: {delay: 0 , repeat: 2 } })
// .replay();
// });

// ### istanbul ignore next ###
if ( (typeof define === "function") && define.amd ) {
define("mojs", [], function () { return mojs; });
Expand Down
2 changes: 1 addition & 1 deletion js/thenable.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Thenable extends Tweenable {
// reset isShowEnd flag for the submodules
obj.isShowEnd = false;
// set the submodule callbacks context
obj.callbacksContext = this;
obj.callbacksContext = this._props.callbacksContext;
return obj;
}
/*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mo-js",
"description": "motion graphics toolbelt for the web",
"version": "0.214.8",
"version": "0.214.9",
"license": "MIT",
"private": false,
"scripts": {
Expand Down
10 changes: 6 additions & 4 deletions spec/thenable.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ describe 'thenable ->', ->
th.then()
expect(th._mergeThenOptions).not.toHaveBeenCalled()

describe 'submodule creation', ->
describe 'submodule creation ->', ->
it 'should create the new Module with options', ->
th = new Thenable radius: 20, duration: 1000, delay: 10
th._defaults = {}
Expand All @@ -389,12 +389,14 @@ describe 'thenable ->', ->
th._vars()
th.then({ stroke: 'cyan' })
expect(th._modules[1]._o.isTimelineLess).toBe true
it 'should pass this as callbacksContext to the submodule', ->
it 'should pass _props.callbacksContext to the submodule', ->
th = new Thenable radius: 20, duration: 1000, delay: 10
th._defaults = {}
th._props.callbacksContext = {}
th._vars()
th.then({ stroke: 'cyan' })
expect(th.timeline._timelines[1]._props.callbacksContext).toBe th
expect(th.timeline._timelines[1]._o.callbacksContext)
.toBe th._props.callbacksContext
it 'should reset isShowStart flag on submodule', ->
th = new Thenable
radius: 20, duration: 1000, delay: 10
Expand Down Expand Up @@ -450,7 +452,7 @@ describe 'thenable ->', ->
expect(obj.isTimelineLess) .toBe true
expect(obj.isShowStart) .toBe false
expect(obj.isShowEnd) .toBe false
expect(obj.callbacksContext).toBe th
expect(obj.callbacksContext).toBe th._props.callbacksContext

describe '_getArrayLength method ->', ->
it 'should get length if array', ->
Expand Down
9 changes: 5 additions & 4 deletions spec/thenable.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@
th.then();
return expect(th._mergeThenOptions).not.toHaveBeenCalled();
});
return describe('submodule creation', function() {
return describe('submodule creation ->', function() {
it('should create the new Module with options', function() {
var th;
th = new Thenable({
Expand Down Expand Up @@ -572,19 +572,20 @@
});
return expect(th._modules[1]._o.isTimelineLess).toBe(true);
});
it('should pass this as callbacksContext to the submodule', function() {
it('should pass _props.callbacksContext to the submodule', function() {
var th;
th = new Thenable({
radius: 20,
duration: 1000,
delay: 10
});
th._defaults = {};
th._props.callbacksContext = {};
th._vars();
th.then({
stroke: 'cyan'
});
return expect(th.timeline._timelines[1]._props.callbacksContext).toBe(th);
return expect(th.timeline._timelines[1]._o.callbacksContext).toBe(th._props.callbacksContext);
});
it('should reset isShowStart flag on submodule', function() {
var th;
Expand Down Expand Up @@ -667,7 +668,7 @@
expect(obj.isTimelineLess).toBe(true);
expect(obj.isShowStart).toBe(false);
expect(obj.isShowEnd).toBe(false);
return expect(obj.callbacksContext).toBe(th);
return expect(obj.callbacksContext).toBe(th._props.callbacksContext);
});
});
return describe('_getArrayLength method ->', function() {
Expand Down

0 comments on commit 324f53a

Please sign in to comment.