diff --git a/DESCRIPTION b/DESCRIPTION index 7d97b752f..73aad0d6f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -64,7 +64,7 @@ Authors@R: c( comment="Animint2 GSoC 2025"), person("Gaurav", "Chaudhary", role="ctb", - comment="Remove unused css.file parameter; fix issue #233 selector values; fix issue #273 update_axes tick font-size; fix issue #276 update_axes transition duration"), + comment="GSOC 2026"), person("Nandani", "Aggarwal", role="ctb", comment="Removed geom_dotplot and replaced with error")) diff --git a/NEWS.md b/NEWS.md index 7c10aef35..7d3d8c548 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,10 @@ - `geom_dotplot()` has been removed. Use `geom_point()` instead for interactive visualizations. (Fixed #289) +# Changes in version 2026.3.2 (PR#306) + +- `animint.js`: Remove redundant `Selectors.hasOwnProperty` checks and use a shared `selector_has_duration()` helper (issue #278, PR#306). + # Changes in version 2025.12.4 (PR#277) - `update_axes`: Fix issue #276 where transition duration was hardcoded to 1000ms. Now it respects the selector's duration. diff --git a/inst/htmljs/animint.js b/inst/htmljs/animint.js index 3bc738f87..382df8962 100644 --- a/inst/htmljs/animint.js +++ b/inst/htmljs/animint.js @@ -101,6 +101,12 @@ var animint = function (to_select, json_file) { return safe_name(selector_name) + "_variable"; } + // selector_name can be null for geoms without a selector (initial render via update_geom(g, null)). + function selector_has_duration(name) { + return name && + Selectors[name].hasOwnProperty("duration"); + } + function is_interactive_aes(v_name){ if(v_name.indexOf("clickSelects") > -1){ return true; @@ -1642,7 +1648,7 @@ var animint = function (to_select, json_file) { eActions = function(groups) { // Handle transitions seperately due to unique structure of geom_label_aligned var transitionDuration = 0; - if (Selectors.hasOwnProperty(selector_name)) { + if(selector_has_duration(selector_name)){ transitionDuration = +Selectors[selector_name].duration || 0; } groups.each(function(d) { @@ -1938,7 +1944,7 @@ var animint = function (to_select, json_file) { positionTooltip(tooltip, tooltip.html()); }); } - if(Selectors.hasOwnProperty(selector_name)){ + if(selector_has_duration(selector_name)){ var milliseconds = Selectors[selector_name].duration; elements = elements.transition().duration(milliseconds); } @@ -2086,7 +2092,7 @@ var animint = function (to_select, json_file) { // update existing axis var xyaxis_sel = element.select("#"+viz_id+"_"+p_name).select("."+axes+"axis_"+panel_i); var milliseconds = 0; - if(v_name && Selectors.hasOwnProperty(v_name) && Selectors[v_name].hasOwnProperty("duration")){ + if(selector_has_duration(v_name)){ milliseconds = Selectors[v_name].duration; } var xyaxis_g = xyaxis_sel @@ -2163,9 +2169,6 @@ var animint = function (to_select, json_file) { } var update_selector = function (v_name, value) { - if(!Selectors.hasOwnProperty(v_name)){ - return; - } value = value + ""; var s_info = Selectors[v_name]; if(s_info.type == "single"){