@zambezi/d3-utils
Advanced tools
Comparing version 3.0.0-5 to 3.0.0-7
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('underscore')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'underscore'], factory) : | ||
(factory((global.d3Utils = global.d3Utils || {}),global.d3,global._)); | ||
}(this, function (exports,d3Selection,underscore) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('underscore'), require('d3-dispatch')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'underscore', 'd3-dispatch'], factory) : | ||
(factory((global.d3Utils = global.d3Utils || {}),global.d3,global._,global.d3)); | ||
}(this, function (exports,d3Selection,underscore,d3Dispatch) { 'use strict'; | ||
@@ -76,5 +76,2 @@ var babelHelpers = {}; | ||
function autoDirty(component) { | ||
console.debug('autoDirty', component); | ||
return function run(s) { | ||
@@ -102,41 +99,2 @@ if (autoSizeDirty) s.dispatch('size-dirty', { bubbles: true }); | ||
function createDispatchCustomEvent() { | ||
var type = void 0, | ||
canBubble = true, | ||
cancelable = true, | ||
detail = void 0; | ||
function dispatchCustomEvent(d, i) { | ||
var evt = document.createEvent('CustomEvent'); | ||
evt.initCustomEvent(type, canBubble, cancelable, detail); | ||
this.dispatchEvent(evt); | ||
} | ||
dispatchCustomEvent.type = function (value) { | ||
if (!arguments.length) return type; | ||
type = value; | ||
return dispatchCustomEvent; | ||
}; | ||
dispatchCustomEvent.canBubble = function (value) { | ||
if (!arguments.length) return canBubble; | ||
canBubble = value; | ||
return dispatchCustomEvent; | ||
}; | ||
dispatchCustomEvent.cancelable = function (value) { | ||
if (!arguments.length) return cancelable; | ||
cancelable = value; | ||
return dispatchCustomEvent; | ||
}; | ||
dispatchCustomEvent.detail = function (value) { | ||
if (!arguments.length) return detail; | ||
detail = value; | ||
return dispatchCustomEvent; | ||
}; | ||
return dispatchCustomEvent; | ||
} | ||
function createResize() { | ||
@@ -238,2 +196,50 @@ var type = underscore.uniqueId('resize.resize_'), | ||
function redispatch() { | ||
var dispatchers = []; | ||
function redispatch() { | ||
return redispatch.create(); | ||
} | ||
redispatch.from = function (dispatcher) { | ||
for (var _len = arguments.length, types = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
types[_key - 1] = arguments[_key]; | ||
} | ||
dispatchers.push({ dispatcher: dispatcher, types: types }); | ||
return redispatch; | ||
}; | ||
redispatch.eventTypes = function () { | ||
return dispatchers.reduce(toTypes, []); | ||
}; | ||
redispatch.create = function () { | ||
var dispatch = d3Dispatch.dispatch.apply(null, dispatchers.reduce(types, [])); | ||
dispatchers.forEach(proxyEvents); | ||
return dispatch; | ||
function proxyEvents(d) { | ||
d.types.forEach(proxyEvent); | ||
function proxyEvent(type) { | ||
d.dispatcher.on(type + '.redispatcher', forward); | ||
function forward() { | ||
dispatch.apply(type, this, arguments); | ||
} | ||
} | ||
} | ||
}; | ||
return redispatch; | ||
function types(acc, next) { | ||
return acc.concat(next.types); | ||
} | ||
function toTypes(acc, v, k) { | ||
return acc.concat(v.types); | ||
} | ||
} | ||
function redraw(component) { | ||
@@ -312,3 +318,2 @@ return function run(s) { | ||
exports.createAutoDirty = createAutoDirty; | ||
exports.createDispatchCustomEvent = createDispatchCustomEvent; | ||
exports.createResize = createResize; | ||
@@ -321,2 +326,3 @@ exports.each = each; | ||
exports.rebind = rebind; | ||
exports.redispatch = redispatch; | ||
exports.redraw = redraw; | ||
@@ -323,0 +329,0 @@ exports.selectionChanged = selectionChanged; |
{ | ||
"name": "@zambezi/d3-utils", | ||
"version": "3.0.0-5", | ||
"version": "3.0.0-7", | ||
"description": "Common utility functions to use with d3", | ||
@@ -35,2 +35,3 @@ "keywords": [ | ||
"dependencies": { | ||
"d3-dispatch": "^1.0.1", | ||
"d3-selection": "^1.0.2", | ||
@@ -37,0 +38,0 @@ "underscore": "^1.8.3" |
@@ -9,3 +9,3 @@ import babel from 'rollup-plugin-babel' | ||
moduleName: 'd3Utils', | ||
external: [ 'd3-selection', 'underscore' ], | ||
external: [ 'd3-selection', 'd3-dispatch', 'underscore' ], | ||
sourceMap: true, | ||
@@ -15,4 +15,5 @@ plugins: [ babel(babelrc()) ], | ||
'underscore': '_', | ||
'd3-selection': 'd3' | ||
'd3-selection': 'd3', | ||
'd3-dispatch': 'd3' | ||
} | ||
} |
@@ -14,5 +14,2 @@ | ||
function autoDirty(component) { | ||
console.debug('autoDirty', component) | ||
return function run(s) { | ||
@@ -19,0 +16,0 @@ if (autoSizeDirty) s.dispatch('size-dirty', { bubbles: true }) |
@@ -5,3 +5,2 @@ export { appendFromTemplate } from './append-from-template' | ||
export { createAutoDirty } from './auto-dirty' | ||
export { createDispatchCustomEvent } from './dispatch-custom-event' | ||
export { createResize } from './resize' | ||
@@ -13,4 +12,5 @@ export { each } from './each' | ||
export { rebind } from './rebind' | ||
export { redispatch } from './redispatch' | ||
export { redraw } from './redraw' | ||
export { selectionChanged } from './selection-changed' | ||
export { throttle } from './throttle' |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35988
523
3
+ Addedd3-dispatch@^1.0.1
+ Addedd3-dispatch@1.0.6(transitive)