From daf73591476eabbc94a3ef95ea45e3854646e59b Mon Sep 17 00:00:00 2001 From: Vitor Baptista Date: Thu, 20 Jul 2017 19:59:31 +0100 Subject: [PATCH] Update demos and HTML files and run build on `prepublish` 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. --- demos/assets/scripts/Tween.js | 104 ++++++++++++++++------------- demos/assets/scripts/bubbletree.js | 11 +++ demos/index.html | 2 +- index.html | 6 +- package.json | 1 + 5 files changed, 74 insertions(+), 50 deletions(-) diff --git a/demos/assets/scripts/Tween.js b/demos/assets/scripts/Tween.js index 3380d22..dcf10e2 100644 --- a/demos/assets/scripts/Tween.js +++ b/demos/assets/scripts/Tween.js @@ -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) { @@ -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; @@ -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; }; @@ -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) { @@ -196,7 +190,7 @@ TWEEN.Tween = function (object) { _isPlaying = false; if (_onStopCallback !== null) { - _onStopCallback.call(_object); + _onStopCallback.call(_object, _object); } this.stopChainedTweens(); @@ -204,6 +198,13 @@ TWEEN.Tween = function (object) { }; + this.end = function () { + + this.update(_startTime + _duration); + return this; + + }; + this.stopChainedTweens = function () { for (var i = 0, numChainedTweens = _chainedTweens.length; i < numChainedTweens; i++) { @@ -226,6 +227,13 @@ TWEEN.Tween = function (object) { }; + this.repeatDelay = function (amount) { + + _repeatDelayTime = amount; + return this; + + }; + this.yoyo = function (yoyo) { _yoyo = yoyo; @@ -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; @@ -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); } } @@ -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) { @@ -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++) { diff --git a/demos/assets/scripts/bubbletree.js b/demos/assets/scripts/bubbletree.js index 25f76d8..16b9d70 100644 --- a/demos/assets/scripts/bubbletree.js +++ b/demos/assets/scripts/bubbletree.js @@ -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) { diff --git a/demos/index.html b/demos/index.html index 5102887..acbd641 100644 --- a/demos/index.html +++ b/demos/index.html @@ -24,13 +24,13 @@

BubbleTree Demos

  • cra
  • cra-map
  • dfid
  • +
  • format-value
  • ira
  • israel
  • minimal
  • random
  • random-evil-taxonomy
  • uganda
  • -
  • custom value format
  • diff --git a/index.html b/index.html index 02693ed..e3849d7 100644 --- a/index.html +++ b/index.html @@ -22,13 +22,13 @@

    Documentation

    Please refer to the docs in the wiki pages.

    -

    Copyright (c) 2011,2012 Open Knowledge International

    +

    Copyright (c) 2011,2012 Open Knowledge Foundation

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), 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:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", 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.

    Attribution Request

    If you use Bubbletree to make a visualization we'd love it (but it's not required!) if you added a small credit text and link e.g.

    -
    Built with <a href="http://okfn.org/">Open Knowledge International's</a> <a href="https://github.com/okfn/bubbletree">Bubbletree library</a>
    +
    Built with <a href="http://okfn.org/">Open Knowledge Foundation's</a> <a href="https://github.com/okfn/bubbletree">Bubbletree library</a>
     

    Authors

    Gregor Aisch with a very small amount of input from Rufus Pollock as part of work on the OpenSpending project and with financial support from Publish What You Fund and the Shuttleworth Foundation.

    Useful commands

    @@ -42,4 +42,4 @@

    Installation

    bower install bubbletree

    - + \ No newline at end of file diff --git a/package.json b/package.json index 6e67557..ff4e111 100644 --- a/package.json +++ b/package.json @@ -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" },