Skip to content

Commit

Permalink
Break the animations
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle committed Nov 9, 2019
1 parent 8af4d8d commit e832349
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/controllers/controller.bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ module.exports = DatasetController.extend({

me._updateElementGeometry(rectangle, index, reset, options);

rectangle.pivot(me.chart._animationsDisabled);
rectangle.pivot();
},

/**
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controller.bubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ module.exports = DatasetController.extend({
y: y,
};

point.pivot(me.chart._animationsDisabled);
point.pivot();
},

/**
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controller.doughnut.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ module.exports = DatasetController.extend({
model.endAngle = model.startAngle + model.circumference;
}

arc.pivot(chart._animationsDisabled);
arc.pivot();
},

calculateTotal: function() {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controller.line.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module.exports = DatasetController.extend({

// Now pivot the point for animation
for (i = 0, ilen = points.length; i < ilen; ++i) {
points[i].pivot(me.chart._animationsDisabled);
points[i].pivot();
}
},

Expand Down
2 changes: 1 addition & 1 deletion src/controllers/controller.polarArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ module.exports = DatasetController.extend({
}
});

arc.pivot(chart._animationsDisabled);
arc.pivot();
},

countVisibleElements: function() {
Expand Down
5 changes: 2 additions & 3 deletions src/controllers/controller.radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ module.exports = DatasetController.extend({
var line = meta.dataset;
var points = meta.data || [];
var config = me._config;
var animationsDisabled = me.chart._animationsDisabled;
var i, ilen;

// Compatibility: If the properties are defined with only the old name, use those values
Expand All @@ -91,7 +90,7 @@ module.exports = DatasetController.extend({
// Model
line._model = me._resolveDatasetElementOptions();

line.pivot(animationsDisabled);
line.pivot();

// Update Points
for (i = 0, ilen = points.length; i < ilen; ++i) {
Expand All @@ -103,7 +102,7 @@ module.exports = DatasetController.extend({

// Now pivot the point for animation
for (i = 0, ilen = points.length; i < ilen; ++i) {
points[i].pivot(animationsDisabled);
points[i].pivot();
}
},

Expand Down
27 changes: 6 additions & 21 deletions src/core/core.element.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,10 @@ class Element {
this.hidden = false;
}

pivot(animationsDisabled) {
pivot() {
var me = this;
if (animationsDisabled) {
me._view = me._model;
return me;
}

if (!me._view) {
me._view = helpers.extend({}, me._model);
}
me._start = {};
me._view = me._model;
me._start = null;
return me;
}

Expand All @@ -83,17 +76,9 @@ class Element {
var start = me._start;
var view = me._view;

// No animation -> No Transition
if (!model || ease === 1) {
// _model has to be cloned to _view
// Otherwise, when _model properties are set on hover, _view.* is also set to the same value, and hover animation doesn't occur
me._view = helpers.extend({}, model);
me._start = null;
return me;
}

if (!view) {
view = me._view = {};
// At first transition, clone _model to _view (we can't change the model directly, can we?)
if (!view || view === model) {
view = me._view = helpers.extend({}, model);
}

if (!start) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ class Tooltip extends Element {
initialize() {
var me = this;
me._model = getBaseModel(me._options);
me._view = {};
me._lastActive = [];
me.pivot();
}

transition(easingValue) {
Expand Down
4 changes: 2 additions & 2 deletions test/specs/core.element.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ describe('Core element tests', function() {
colorProp: 'rgb(64, 64, 0)',
});

// Final transition clones model into view
// Final transition does not close _model to _view anymore
element.transition(1);

expect(element._view).toEqual(element._model);
expect(element._view).not.toEqual(element._model);
expect(element._view).not.toBe(element._model);
});
});

0 comments on commit e832349

Please sign in to comment.