Skip to content

Commit 08552bd

Browse files
authored
Merge pull request #390 from Ajayneethikannan/modify_DOM_example
corrects errors present in modifying DOM example
2 parents bda253e + 5000fc4 commit 08552bd

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

src/data/examples/en/16_Dom/07_Modify_DOM.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ let dancingWords = [];
1111
class DanceSpan {
1212
constructor(element, x, y) {
1313
element.position(x, y);
14+
this.element = element;
15+
this.x = x;
16+
this.y = y;
1417
}
1518

1619
brownian() {
17-
x += random(-6, 6);
18-
y += random(-6, 6);
19-
element.position(x, y);
20+
this.x += random(-6, 6);
21+
this.y += random(-6, 6);
22+
this.element.position(this.x, this.y);
2023
}
2124
}
2225

@@ -28,7 +31,7 @@ function setup() {
2831
createP(
2932
'I learn in this Letter, that Don Peter of Aragon, ' +
3033
' comes this night to Messina'
31-
).addClass('text');
34+
).addClass('text').hide();
3235

3336
// This line grabs the paragraph just created, but it would
3437
// also grab any other elements with class 'text' in the HTML

src/data/examples/es/16_Dom/07_Modify_DOM.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ let dancingWords = [];
1111
class DanceSpan {
1212
constructor(element, x, y) {
1313
element.position(x, y);
14+
this.element = element;
15+
this.x = x;
16+
this.y = y;
1417
}
1518

1619
brownian() {
17-
x += random(-6, 6);
18-
y += random(-6, 6);
19-
element.position(x, y);
20+
this.x += random(-6, 6);
21+
this.y += random(-6, 6);
22+
this.element.position(this.x, this.y);
2023
}
2124
}
2225

@@ -25,9 +28,9 @@ function setup() {
2528
// Es para diferenciar entre la creación de un elemento y su selección.
2629
// Los elementos seleccionados no necesitan ser creados por p5js, pueden ser HTML plano.
2730
createP(
28-
'I learne in this Letter, that Don Peter of Arragon, ' +
31+
'I learn in this Letter, that Don Peter of Arragon, ' +
2932
' comes this night to Messina'
30-
).addClass('text');
33+
).addClass('text').hide();
3134

3235
// Esta línea toma el párrafo recién creado, pero podría también
3336
// tomar otros elementos de la clase 'text' en la página HTML.

src/data/examples/zh-Hans/16_Dom/07_Modify_DOM.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ let dancingWords = [];
1111
class DanceSpan {
1212
constructor(element, x, y) {
1313
element.position(x, y);
14+
this.element = element;
15+
this.x = x;
16+
this.y = y;
1417
}
1518

1619
brownian() {
17-
x += random(-6, 6);
18-
y += random(-6, 6);
19-
element.position(x, y);
20+
this.x += random(-6, 6);
21+
this.y += random(-6, 6);
22+
this.element.position(this.x, this.y);
2023
}
2124
}
2225

@@ -28,7 +31,7 @@ function setup() {
2831
createP(
2932
'I learn in this Letter, that Don Peter of Aragon, ' +
3033
' comes this night to Messina'
31-
).addClass('text');
34+
).addClass('text').hide();
3235

3336
// This line grabs the paragraph just created, but it would
3437
// also grab any other elements with class 'text' in the HTML

0 commit comments

Comments
 (0)