block by 1wheel 75449cf6cc106e8533d767eb2c5f0232

selection-multi and transition rollup

Full Screen

forked from D3 Custom Bundle II

styles after the transition wasn’t working. I needed to modify node_modules/d3-selection-multi/index.js to update the transition prototype:

import {selection} from "d3-selection";
import selection_attrs from "./src/selection_attrs";
import selection_styles from "./src/selection_styles";
import selection_properties from "./src/selection_properties";

selection.prototype.attrs = selection_attrs;
selection.prototype.styles = selection_styles; = selection_properties;

if (selection.prototype.transition){
  selection.prototype.transition.attrs = selection_attrs;
  selection.prototype.transition.styles = selection_attrs; = selection_attrs;

This seems way too hacky since it there’s an unspecified dependency on loading d3-transition before d3-selection-multi. I’m not sure if there should be a separate d3-selection-transition-multi module to handle this? Creating two modules for everything you’d like to stick onto selection.prototype seems like overkill.

To use attrs after a transition now, just add this to the top of your code:

d3.selection.prototype.transition.attrs = d3.selection.prototype.attrs