@flourish/controls
Advanced tools
{ | ||
"name": "@flourish/controls", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Switchable Dropdown/buttons/slider control", | ||
@@ -5,0 +5,0 @@ "main": "controls.js", |
@@ -25,6 +25,27 @@ import Slider from "@flourish/slider"; | ||
injectCSS(css_string); | ||
var output_obj = {}; | ||
update = update || function() {}; | ||
var options, visible_control, current_value, width, is_animatable; | ||
var props = {}; | ||
var props = { | ||
options: [], | ||
"data_type": "categorical", | ||
"control_type": "dropdown", | ||
width: "300", | ||
"step_time": 2, | ||
"loop_time": 1.5, | ||
"handle_colour": "#73bef7" | ||
}; | ||
Object.keys(props).forEach(function(key) { | ||
var methodName = key.replace(/_\w/g, function(substr) { return substr.charAt(1).toUpperCase(); }); | ||
output_obj[methodName] = function(value){ | ||
if(value === undefined) return props[key]; | ||
props[key] = value; | ||
return this; | ||
}; | ||
} ); | ||
Object.defineProperty(props, "value", { | ||
@@ -35,4 +56,2 @@ get: function() { return state_obj[value_value]; }, | ||
injectCSS(css_string); | ||
// Grab container | ||
@@ -297,11 +316,5 @@ var container = select(container_selector).classed("controls-container", true); | ||
var setProps = function(new_props) { | ||
prop_list.forEach(function(prop) { | ||
props[prop] = new_props[prop]; | ||
} ); | ||
}; | ||
var updateControls = function(new_props) { | ||
if (!updateControlOptions(new_props.options)) return; | ||
setProps(new_props); | ||
var updateControls = function() { | ||
if (!updateControlOptions(props.options)) return; | ||
updateControlWidth(); | ||
@@ -314,9 +327,8 @@ updateControlAnimation(); | ||
output_obj.showDropdownList = function() { showDropdownList(); return this; }; | ||
output_obj.hideDropdownList = function() { showDropdownList(); return this; }; | ||
output_obj.toggleDropdownList = function() { showDropdownList(); return this; }; | ||
output_obj.update = function() { updateControls(); return this; }; | ||
return { | ||
showDropdownList: showDropdownList, | ||
hideDropdownList: hideDropdownList, | ||
toggleDropdownList: toggleDropdownList, | ||
updateControls: function(new_props) { updateControls(new_props); return this; } | ||
}; | ||
return output_obj; | ||
@@ -323,0 +335,0 @@ } |
Sorry, the diff of this file is too big to display
114448
0.76%3087
0.65%