Skip to content

Commit

Permalink
remove callback from dc.transition
Browse files Browse the repository at this point in the history
in preparation for #1116

this was a confusing parameter, invoked when it was decided that there
would be a transition. since we used it in exactly the case where we
were calling attrTween, and we already had to check that in another
place, seems clearer just to check that every time.

(it was also going to make it impossible to add an int/function-typed
parameter)
  • Loading branch information
gordonwoodhull committed Nov 25, 2016
1 parent 2459ee2 commit a035b19
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
16 changes: 0 additions & 16 deletions spec/core-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ describe('dc.core', function () {
expect(selections.transition).toHaveBeenCalled();
expect(selections.duration).toHaveBeenCalled();
});

it('transition callback should be triggered', function () {
var triggered = false;
dc.transition(selections, 100, function () {
triggered = true;
});
expect(triggered).toBeTruthy();
});
});

describe('skip', function () {
Expand All @@ -135,14 +127,6 @@ describe('dc.core', function () {
expect(selections.transition).not.toHaveBeenCalled();
expect(selections.duration).not.toHaveBeenCalled();
});

it('transition callback should not be triggered', function () {
var triggered = false;
dc.transition(selections, 0, function () {
triggered = true;
});
expect(triggered).toBeFalsy();
});
});
});

Expand Down
6 changes: 1 addition & 5 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ dc.redrawAll = function (group) {
*/
dc.disableTransitions = false;

dc.transition = function (selections, duration, callback, name) {
dc.transition = function (selections, duration, name) {
if (duration <= 0 || duration === undefined || dc.disableTransitions) {
return selections;
}
Expand All @@ -274,10 +274,6 @@ dc.transition = function (selections, duration, callback, name) {
.transition(name)
.duration(duration);

if (typeof(callback) === 'function') {
callback(s);
}

return s;
};

Expand Down
16 changes: 9 additions & 7 deletions src/pie-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ dc.pieChart = function (parent, chartGroup) {
return safeArc(d, i, arc);
});

dc.transition(slicePath, _chart.transitionDuration(), function (s) {
s.attrTween('d', tweenPie);
});
var transition = dc.transition(slicePath, _chart.transitionDuration());
if (transition.attrTween) {
transition.attrTween('d', tweenPie);
}
}

function createTitles (slicesEnter) {
Expand Down Expand Up @@ -276,10 +277,11 @@ dc.pieChart = function (parent, chartGroup) {
.attr('d', function (d, i) {
return safeArc(d, i, arc);
});
dc.transition(slicePaths, _chart.transitionDuration(),
function (s) {
s.attrTween('d', tweenPie);
}).attr('fill', fill);
var transition = dc.transition(slicePaths, _chart.transitionDuration());
if (transition.attrTween) {
transition.attrTween('d', tweenPie);
}
transition.attr('fill', fill);
}

function updateLabels (pieData, arc) {
Expand Down

0 comments on commit a035b19

Please sign in to comment.