Skip to content

Commit

Permalink
Update demos and HTML files and run build on prepublish
Browse files Browse the repository at this point in the history
This was after running `npm run build`. Apparently it has been a while since
the code was built. To avoid pushing old code to npm, I also added `npm run
build` in the `prepublish` script.
  • Loading branch information
vitorbaptista committed Aug 3, 2017
1 parent bef2eee commit daf7359
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 50 deletions.
104 changes: 58 additions & 46 deletions demos/assets/scripts/Tween.js
Expand Up @@ -69,37 +69,34 @@ var TWEEN = TWEEN || (function () {
})();


// Include a performance.now polyfill
(function () {
// In node.js, use process.hrtime.
if (this.window === undefined && this.process !== undefined) {
TWEEN.now = function () {
var time = process.hrtime();

// Convert [seconds, microseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000;
};
}
// In a browser, use window.performance.now if it is available.
else if (this.window !== undefined &&
window.performance !== undefined &&
// Include a performance.now polyfill.
// In node.js, use process.hrtime.
if (typeof (window) === 'undefined' && typeof (process) !== 'undefined') {
TWEEN.now = function () {
var time = process.hrtime();

// Convert [seconds, nanoseconds] to milliseconds.
return time[0] * 1000 + time[1] / 1000000;
};
}
// In a browser, use window.performance.now if it is available.
else if (typeof (window) !== 'undefined' &&
window.performance !== undefined &&
window.performance.now !== undefined) {

// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
TWEEN.now = window.performance.now.bind(window.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
TWEEN.now = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
TWEEN.now = function () {
return new Date().getTime();
};
}
})();
// This must be bound, because directly assigning this function
// leads to an invocation exception in Chrome.
TWEEN.now = window.performance.now.bind(window.performance);
}
// Use Date.now if it is available.
else if (Date.now !== undefined) {
TWEEN.now = Date.now;
}
// Otherwise, use 'new Date().getTime()'.
else {
TWEEN.now = function () {
return new Date().getTime();
};
}


TWEEN.Tween = function (object) {
Expand All @@ -110,6 +107,7 @@ TWEEN.Tween = function (object) {
var _valuesStartRepeat = {};
var _duration = 1000;
var _repeat = 0;
var _repeatDelayTime;
var _yoyo = false;
var _isPlaying = false;
var _reversed = false;
Expand All @@ -124,19 +122,14 @@ TWEEN.Tween = function (object) {
var _onCompleteCallback = null;
var _onStopCallback = null;

// Set all starting values present on the target object
for (var field in object) {
_valuesStart[field] = parseFloat(object[field], 10);
}

this.to = function (properties, duration) {

_valuesEnd = properties;

if (duration !== undefined) {
_duration = duration;
}

_valuesEnd = properties;

return this;

};
Expand Down Expand Up @@ -168,10 +161,11 @@ TWEEN.Tween = function (object) {

// If `to()` specifies a property that doesn't exist in the source object,
// we should not set that property in the object
if (_valuesStart[property] === undefined) {
if (_object[property] === undefined) {
continue;
}

// Save the starting value.
_valuesStart[property] = _object[property];

if ((_valuesStart[property] instanceof Array) === false) {
Expand All @@ -196,14 +190,21 @@ TWEEN.Tween = function (object) {
_isPlaying = false;

if (_onStopCallback !== null) {
_onStopCallback.call(_object);
_onStopCallback.call(_object, _object);
}

this.stopChainedTweens();
return this;

};

this.end = function () {

this.update(_startTime + _duration);
return this;

};

this.stopChainedTweens = function () {

for (var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++) {
Expand All @@ -226,6 +227,13 @@ TWEEN.Tween = function (object) {

};

this.repeatDelay = function (amount) {

_repeatDelayTime = amount;
return this;

};

this.yoyo = function (yoyo) {

_yoyo = yoyo;
Expand Down Expand Up @@ -296,11 +304,10 @@ TWEEN.Tween = function (object) {
if (_onStartCallbackFired === false) {

if (_onStartCallback !== null) {
_onStartCallback.call(_object);
_onStartCallback.call(_object, _object);
}

_onStartCallbackFired = true;

}

elapsed = (time - _startTime) / _duration;
Expand Down Expand Up @@ -328,9 +335,9 @@ TWEEN.Tween = function (object) {
if (typeof (end) === 'string') {

if (end.charAt(0) === '+' || end.charAt(0) === '-') {
end = start + parseFloat(end, 10);
end = start + parseFloat(end);
} else {
end = parseFloat(end, 10);
end = parseFloat(end);
}
}

Expand Down Expand Up @@ -359,7 +366,7 @@ TWEEN.Tween = function (object) {
for (property in _valuesStartRepeat) {

if (typeof (_valuesEnd[property]) === 'string') {
_valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property], 10);
_valuesStartRepeat[property] = _valuesStartRepeat[property] + parseFloat(_valuesEnd[property]);
}

if (_yoyo) {
Expand All @@ -377,14 +384,19 @@ TWEEN.Tween = function (object) {
_reversed = !_reversed;
}

_startTime = time + _delayTime;
if (_repeatDelayTime !== undefined) {
_startTime = time + _repeatDelayTime;
} else {
_startTime = time + _delayTime;
}

return true;

} else {

if (_onCompleteCallback !== null) {
_onCompleteCallback.call(_object);

_onCompleteCallback.call(_object, _object);
}

for (var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++) {
Expand Down
11 changes: 11 additions & 0 deletions demos/assets/scripts/bubbletree.js
Expand Up @@ -794,6 +794,17 @@ var BubbleTree = function(config, onHover, onUnHover) {
node[prop] = styles[node.taxonomy][node.name][prop];
}
});

if (styles.getStyle) {
// Overwrite the styles with what we get back from styles.getStyle()
var style = styles.getStyle(node, index);

$.each(props, function (p, prop) {
if (style.hasOwnProperty(prop)) {
node[prop] = style[prop];
}
});
}
}

if (!node.color) {
Expand Down
2 changes: 1 addition & 1 deletion demos/index.html
Expand Up @@ -24,13 +24,13 @@ <h1>BubbleTree Demos</h1>
<li><a href="cra/index.html">cra</a></li>
<li><a href="cra-map/index.html">cra-map</a></li>
<li><a href="dfid/index.html">dfid</a></li>
<li><a href="format-value/index.html">format-value</a></li>
<li><a href="ira/index.html">ira</a></li>
<li><a href="israel/index.html">israel</a></li>
<li><a href="minimal/index.html">minimal</a></li>
<li><a href="random/index.html">random</a></li>
<li><a href="random-evil-taxonomy/index.html">random-evil-taxonomy</a></li>
<li><a href="uganda/index.html">uganda</a></li>
<li><a href="format-value/index.html">custom value format</a></li>
</ul>

</div>
Expand Down
6 changes: 3 additions & 3 deletions index.html
Expand Up @@ -22,13 +22,13 @@
<h2 id="documentation">Documentation</h2>
<p>Please refer to the docs in the <a href="https://github.com/okfn/bubbletree/wiki/Bubble-Tree-Documentation">wiki pages</a>.</p>
<h2 id="copyright-and-license">Copyright and License</h2>
<p>Copyright (c) 2011,2012 Open Knowledge International</p>
<p>Copyright (c) 2011,2012 Open Knowledge Foundation</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the &quot;Software&quot;), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
<h2 id="attribution-request">Attribution Request</h2>
<p>If you use Bubbletree to make a visualization we&#39;d love it (but it&#39;s not required!) if you added a small credit text and link e.g.</p>
<pre><code>Built with &lt;a href=&quot;http://okfn.org/&quot;&gt;Open Knowledge International&#39;s&lt;/a&gt; &lt;a href=&quot;https://github.com/okfn/bubbletree&quot;&gt;Bubbletree library&lt;/a&gt;
<pre><code>Built with &lt;a href=&quot;http://okfn.org/&quot;&gt;Open Knowledge Foundation&#39;s&lt;/a&gt; &lt;a href=&quot;https://github.com/okfn/bubbletree&quot;&gt;Bubbletree library&lt;/a&gt;
</code></pre><h2 id="authors">Authors</h2>
<p><a href="http://vis4.net/blog/">Gregor Aisch</a> with a very small amount of input from <a href="http://rufuspollock.org/">Rufus Pollock</a> as part of work on the <a href="http://openspending.org/">OpenSpending</a> project and with financial support from <a href="http://www.publishwhatyoufund.org/">Publish What You Fund</a> and the <a href="http://www.shuttleworthfoundation.org/">Shuttleworth Foundation</a>.</p>
<h2 id="useful-commands">Useful commands</h2>
Expand All @@ -42,4 +42,4 @@ <h2 id="installation">Installation</h2>
<p><code>bower install bubbletree</code> </p>
</div>
</body>
</html>
</html>
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -5,6 +5,7 @@
"main": "dist/bubbletree.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"prepublish": "npm run build",
"build": "gulp",
"review": "jscs src"
},
Expand Down

0 comments on commit daf7359

Please sign in to comment.