Skip to content

Commit

Permalink
custom shape: fix _length calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
legomushroom committed Jun 5, 2016
1 parent 789b0ea commit 93104b8
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,7 +1,7 @@
{
"name": "mojs",
"description": "motion graphics toolbelt for the web",
"version": "0.258.2",
"version": "0.258.4",
"license": "MIT",
"homepage": "https://github.com/legomushroom/mojs",
"authors": [
Expand Down
6 changes: 3 additions & 3 deletions build/mo.js
Expand Up @@ -7808,6 +7808,7 @@
this._defaults.parent = null;

// remove `stroke-width` from `_drawMap`
// because we need to recal strokeWidth size regarding scale
for (var i = 0; i < this._drawMap.length; i++) {
if (this._drawMap[i] === 'stroke-width') {
this._drawMap.splice(i, 1);
Expand Down Expand Up @@ -7874,7 +7875,7 @@
}
this._isRendered = true;

this.getLength();
this._length = this.getLength();

var p = this._props;
p.parent.innerHTML = '<svg id="js-mojs-shape-canvas" xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink"><g id="js-mojs-shape-el">' + this.getShape() + '</g></svg>';
Expand Down Expand Up @@ -8546,7 +8547,7 @@
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var mojs = {
revision: '0.258.2', isDebug: true, helpers: _h2.default,
revision: '0.258.4', isDebug: true, helpers: _h2.default,
Shape: _shape2.default, ShapeSwirl: _shapeSwirl2.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
Expand All @@ -8566,7 +8567,6 @@

// TODO:
/*
stroke dash array for custom shapes
immutable delta parsing
swirl generate issue
Expand Down
10 changes: 5 additions & 5 deletions build/mo.min.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions js/mojs.babel.js
Expand Up @@ -17,7 +17,7 @@ import tweener from './tween/tweener';
import easing from './easing/easing';

var mojs = {
revision: '0.258.2', isDebug: true, helpers: h,
revision: '0.258.4', isDebug: true, helpers: h,
Shape, ShapeSwirl, Burst, stagger, Spriter, MotionPath,
Tween, Timeline, Tweenable, Thenable, Tunable, Module,
tweener, easing, shapesMap
Expand All @@ -37,7 +37,6 @@ window.mojs = mojs;

// TODO:
/*
stroke dash array for custom shapes
immutable delta parsing
swirl generate issue
Expand All @@ -51,7 +50,6 @@ window.mojs = mojs;
percentage for radius
*/


// istanbul ignore next
if ( (typeof define === "function") && define.amd ) {
define("mojs", [], function () { return mojs; });
Expand Down
3 changes: 2 additions & 1 deletion js/shapes/custom.babel.js
Expand Up @@ -13,6 +13,7 @@ class Custom extends Bit {
this._defaults.parent = null;

// remove `stroke-width` from `_drawMap`
// because we need to recal strokeWidth size regarding scale
for (var i = 0; i < this._drawMap.length; i++) {
if ( this._drawMap[i] === 'stroke-width' ) {
this._drawMap.splice( i, 1 );
Expand Down Expand Up @@ -65,7 +66,7 @@ class Custom extends Bit {
if ( this._isRendered ) { return; }
this._isRendered = true;

this.getLength();
this._length = this.getLength();

var p = this._props;
p.parent.innerHTML = `<svg id="js-mojs-shape-canvas" xmlns=\"http://www.w3.org/2000/svg\" xlink=\"http://www.w3.org/1999/xlink\"><g id=\"js-mojs-shape-el\">${this.getShape()}</g></svg>`;
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "mo-js",
"description": "motion graphics toolbelt for the web",
"version": "0.258.3",
"version": "0.258.4",
"license": "MIT",
"private": false,
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions spec/shapes/custom.coffee
Expand Up @@ -99,6 +99,13 @@ describe 'Custom ->', ->
custom._render()
expect(custom._props.parent.innerHTML).toBe ''

it 'should set _length', ->
custom = new Custom parent: parent
custom._isRendered = false
custom._length = null
custom._render()
expect(custom._length).toBe custom.getLength()

describe '_getScale method ->', ->
it 'should calculate x scale', ->
radiusX = 25
Expand Down
11 changes: 10 additions & 1 deletion spec/shapes/custom.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 93104b8

Please sign in to comment.