Skip to content

Commit c82b498

Browse files
committed
Remove resize handler (now integrated into the lib)
1 parent 7e0f504 commit c82b498

9 files changed

Lines changed: 1 addition & 91 deletions

example/axes.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ const deselectHandler = () => {
7777

7878
const scatterplot = createScatterplot({
7979
canvas,
80-
width,
81-
height,
8280
pointSize,
8381
xScale,
8482
yScale,
@@ -106,8 +104,6 @@ const resizeHandler = () => {
106104
// Render grid
107105
xAxis.tickSizeInner(-height);
108106
yAxis.tickSizeInner(-width);
109-
110-
scatterplot.set({ width, height });
111107
};
112108

113109
window.addEventListener('resize', resizeHandler);

example/connected-points-by-segments.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ const exampleEl = document.querySelector(
1818
exampleEl.setAttribute('class', 'active');
1919
exampleEl.removeAttribute('href');
2020

21-
let { width, height } = canvas.getBoundingClientRect();
22-
2321
let points = [];
2422
let numPoints = 9000;
2523
let pointSize = 1;
@@ -53,8 +51,6 @@ const deselectHandler = () => {
5351

5452
const scatterplot = createScatterplot({
5553
canvas,
56-
width,
57-
height,
5854
lassoMinDelay,
5955
lassoMinDist,
6056
pointSize,
@@ -70,13 +66,6 @@ console.log(`Scatterplot v${scatterplot.get('version')}`);
7066
scatterplot.subscribe('select', selectHandler);
7167
scatterplot.subscribe('deselect', deselectHandler);
7268

73-
const resizeHandler = () => {
74-
({ width, height } = canvas.getBoundingClientRect());
75-
scatterplot.set({ width, height });
76-
};
77-
78-
window.addEventListener('resize', resizeHandler);
79-
8069
const generatePoints = (num) => {
8170
const numPointsPerGroup = Math.round(num / 3); // 9.000 / 3 => 3000
8271
const numPointsPerStep = Math.round(numPointsPerGroup / 5); // 3000 / 5 => 600

example/connected-points.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ const exampleEl = document.querySelector('#example-connected-points');
1616
exampleEl.setAttribute('class', 'active');
1717
exampleEl.removeAttribute('href');
1818

19-
let { width, height } = canvas.getBoundingClientRect();
20-
2119
let points = [];
2220
let numPoints = 9000;
2321
let pointSize = 1;
@@ -51,8 +49,6 @@ const deselectHandler = () => {
5149

5250
const scatterplot = createScatterplot({
5351
canvas,
54-
width,
55-
height,
5652
lassoMinDelay,
5753
lassoMinDist,
5854
pointSize,
@@ -68,13 +64,6 @@ console.log(`Scatterplot v${scatterplot.get('version')}`);
6864
scatterplot.subscribe('select', selectHandler);
6965
scatterplot.subscribe('deselect', deselectHandler);
7066

71-
const resizeHandler = () => {
72-
({ width, height } = canvas.getBoundingClientRect());
73-
scatterplot.set({ width, height });
74-
};
75-
76-
window.addEventListener('resize', resizeHandler);
77-
7867
const generatePoints = (num) => {
7968
const numPointsPerGroup = Math.round(num / 3); // 9.000 / 3 => 3000
8069
const numPointsPerStep = Math.round(numPointsPerGroup / 5); // 3000 / 5 => 600

example/index.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ const exampleEl = document.querySelector('#example-basic');
1616
exampleEl.setAttribute('class', 'active');
1717
exampleEl.removeAttribute('href');
1818

19-
let { width, height } = canvas.getBoundingClientRect();
20-
2119
let points = [];
2220
let numPoints = 100000;
2321
let pointSize = 2;
@@ -64,8 +62,6 @@ const deselectHandler = () => {
6462

6563
const scatterplot = createScatterplot({
6664
canvas,
67-
width,
68-
height,
6965
lassoMinDelay,
7066
lassoMinDist,
7167
pointSize,
@@ -80,13 +76,6 @@ scatterplot.subscribe('pointout', pointoutHandler);
8076
scatterplot.subscribe('select', selectHandler);
8177
scatterplot.subscribe('deselect', deselectHandler);
8278

83-
const resizeHandler = () => {
84-
({ width, height } = canvas.getBoundingClientRect());
85-
scatterplot.set({ width, height });
86-
};
87-
88-
window.addEventListener('resize', resizeHandler);
89-
9079
const generatePoints = (num) =>
9180
new Array(num).fill().map(() => [
9281
-1 + Math.random() * 2, // x

example/performance-mode.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ const exampleEl = document.querySelector('#example-performance-mode');
2020
exampleEl.setAttribute('class', 'active');
2121
exampleEl.removeAttribute('href');
2222

23-
let { width, height } = canvas.getBoundingClientRect();
24-
2523
let points = [];
2624
let numPoints = 20000000;
2725
let pointSize = 0.25;
@@ -70,8 +68,6 @@ const deselectHandler = () => {
7068

7169
const scatterplot = createScatterplot({
7270
canvas,
73-
width,
74-
height,
7571
lassoMinDelay,
7672
lassoMinDist,
7773
pointSize,
@@ -84,13 +80,6 @@ console.log(`Scatterplot v${scatterplot.get('version')}`);
8480
scatterplot.subscribe('select', selectHandler);
8581
scatterplot.subscribe('deselect', deselectHandler);
8682

87-
const resizeHandler = () => {
88-
({ width, height } = canvas.getBoundingClientRect());
89-
scatterplot.set({ width, height });
90-
};
91-
92-
window.addEventListener('resize', resizeHandler);
93-
9483
const setNumPoint = (newNumPoints) => {
9584
showModal(
9685
`Hang tight. Generating ${(numPoints / 1000000).toFixed(

example/size-encoding.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ const exampleEl = document.querySelector('#example-size-encoding');
1919
exampleEl.setAttribute('class', 'active');
2020
exampleEl.removeAttribute('href');
2121

22-
let { width, height } = canvas.getBoundingClientRect();
23-
2422
let points = [];
2523
let numPoints = 100000;
2624
let pointSize = 2;
@@ -50,8 +48,6 @@ const deselectHandler = () => {
5048

5149
const scatterplot = createScatterplot({
5250
canvas,
53-
width,
54-
height,
5551
lassoMinDelay,
5652
lassoMinDist,
5753
pointSize,
@@ -64,13 +60,6 @@ console.log(`Scatterplot v${scatterplot.get('version')}`);
6460
scatterplot.subscribe('select', selectHandler);
6561
scatterplot.subscribe('deselect', deselectHandler);
6662

67-
const resizeHandler = () => {
68-
({ width, height } = canvas.getBoundingClientRect());
69-
scatterplot.set({ width, height });
70-
};
71-
72-
window.addEventListener('resize', resizeHandler);
73-
7463
const rndA = randomExponential(2);
7564
const rndB = randomExponential(4);
7665
const rndC = randomExponential(5);

example/texture-background.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const exampleEl = document.querySelector('#example-background');
1616
exampleEl.setAttribute('class', 'active');
1717
exampleEl.removeAttribute('href');
1818

19-
let { width, height } = canvas.getBoundingClientRect();
19+
const { width, height } = canvas.getBoundingClientRect();
2020

2121
let points = [];
2222
let numPoints = 100000;
@@ -42,8 +42,6 @@ const deselectHandler = () => {
4242

4343
const scatterplot = createScatterplot({
4444
canvas,
45-
width,
46-
height,
4745
pointSize,
4846
showRecticle: true,
4947
backgroundImage: `https://picsum.photos/${Math.min(640, width)}/${Math.min(
@@ -57,13 +55,6 @@ console.log(`Scatterplot v${scatterplot.get('version')}`);
5755
scatterplot.subscribe('select', selectHandler);
5856
scatterplot.subscribe('deselect', deselectHandler);
5957

60-
const resizeHandler = () => {
61-
({ width, height } = canvas.getBoundingClientRect());
62-
scatterplot.set({ width, height });
63-
};
64-
65-
window.addEventListener('resize', resizeHandler);
66-
6758
const generatePoints = (num) =>
6859
new Array(num).fill().map(() => [
6960
-1 + Math.random() * 2, // x

example/transition.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ const exampleEl = document.querySelector('#example-transition');
1616
exampleEl.setAttribute('class', 'active');
1717
exampleEl.removeAttribute('href');
1818

19-
let { width, height } = canvas.getBoundingClientRect();
20-
2119
let points = [];
2220
let pointStates = [];
2321
let numPoints = 100000;
@@ -48,8 +46,6 @@ const deselectHandler = () => {
4846

4947
const scatterplot = createScatterplot({
5048
canvas,
51-
width,
52-
height,
5349
lassoMinDelay,
5450
lassoMinDist,
5551
pointSize,
@@ -62,13 +58,6 @@ console.log(`Scatterplot v${scatterplot.get('version')}`);
6258
scatterplot.subscribe('select', selectHandler);
6359
scatterplot.subscribe('deselect', deselectHandler);
6460

65-
const resizeHandler = () => {
66-
({ width, height } = canvas.getBoundingClientRect());
67-
scatterplot.set({ width, height });
68-
};
69-
70-
window.addEventListener('resize', resizeHandler);
71-
7261
const generatePoints = (num) => [
7362
...new Array(Math.round(num / 2)).fill().map(() => [
7463
-1 + Math.random(), // x

example/two-instances.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ exampleEl.setAttribute('class', 'active');
2828
exampleEl.removeAttribute('href');
2929

3030
[canvas1, canvas2].forEach((canvas) => {
31-
let { width, height } = canvas.getBoundingClientRect();
32-
3331
let points = [];
3432
let numPoints = 25000;
3533
let pointSize = 3;
@@ -54,8 +52,6 @@ exampleEl.removeAttribute('href');
5452

5553
const scatterplot = createScatterplot({
5654
canvas,
57-
width,
58-
height,
5955
pointSize,
6056
});
6157

@@ -64,13 +60,6 @@ exampleEl.removeAttribute('href');
6460
scatterplot.subscribe('select', selectHandler);
6561
scatterplot.subscribe('deselect', deselectHandler);
6662

67-
const resizeHandler = () => {
68-
({ width, height } = canvas.getBoundingClientRect());
69-
scatterplot.set({ width, height });
70-
};
71-
72-
window.addEventListener('resize', resizeHandler);
73-
7463
const generatePoints = (num) =>
7564
new Array(num).fill().map(() => [
7665
-1 + Math.random() * 2, // x

0 commit comments

Comments
 (0)