Skip to content

Commit

Permalink
Fix responsive resize on rtl page (chartjs#6063)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle authored and simonbrunel committed Feb 13, 2019
1 parent a6efc15 commit 72b806f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/platforms/platform.dom.css
Expand Up @@ -19,6 +19,7 @@
.chartjs-size-monitor-expand,
.chartjs-size-monitor-shrink {
position: absolute;
direction: ltr;
left: 0;
top: 0;
right: 0;
Expand Down
40 changes: 40 additions & 0 deletions test/specs/core.controller.tests.js
Expand Up @@ -379,6 +379,46 @@ describe('Chart', function() {
});
});

it('should resize the canvas when parent is RTL and width changes', function(done) {
var chart = acquireChart({
options: {
responsive: true,
maintainAspectRatio: false
}
}, {
canvas: {
style: ''
},
wrapper: {
style: 'width: 300px; height: 350px; position: relative; direction: rtl'
}
});

expect(chart).toBeChartOfSize({
dw: 300, dh: 350,
rw: 300, rh: 350,
});

var wrapper = chart.canvas.parentNode;
wrapper.style.width = '455px';
waitForResize(chart, function() {
expect(chart).toBeChartOfSize({
dw: 455, dh: 350,
rw: 455, rh: 350,
});

wrapper.style.width = '150px';
waitForResize(chart, function() {
expect(chart).toBeChartOfSize({
dw: 150, dh: 350,
rw: 150, rh: 350,
});

done();
});
});
});

it('should resize the canvas when parent height changes', function(done) {
var chart = acquireChart({
options: {
Expand Down

0 comments on commit 72b806f

Please sign in to comment.