Skip to content

Commit 1a60d64

Browse files
committed
Canvas.removeFromDOM(canvas) will remove a canvas element from the DOM.
Game.destroy now removes the games canvas element from the DOM.
1 parent 97d771c commit 1a60d64

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
- [Bugs?](#bugs)
2020
- [License](#license)
2121

22-
2322
# Phaser 2.1.0-dev <a name="about"></a>
2423

2524
Phaser is a fast, free and fun open source game framework for making desktop and mobile browser HTML5 games. It uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) internally for fast 2D Canvas and WebGL rendering.
@@ -101,6 +100,8 @@ Version 2.1.0 - "Cairhien" - -in development-
101100
* Animation.onUpdate is a new event that is dispatched each time the animation frame changes. Due to its intensive nature it is disabled by default. Enable it with `Animation.enableUpdate = true` (#902)
102101
* Device now has new features to support detection of running inside a CocoonJS.App (thanks @videlais #1150)
103102
* Support for CocoonJS.App's 'onSuspended' and 'onActivated' events, making it so that the timers and sounds are stopped/started and muted/unmuted when the user swaps an app from the background to the fore or the reverse (thanks @videlais #1152)
103+
* Canvas.removeFromDOM(canvas) will remove a canvas element from the DOM.
104+
* Game.destroy now removes the games canvas element from the DOM.
104105

105106
### Updates
106107

src/core/Game.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,8 @@ Phaser.Game.prototype = {
774774
this.world = null;
775775
this.isBooted = false;
776776

777+
Phaser.Canvas.removeFromDOM(this.canvas);
778+
777779
},
778780

779781
/**

src/system/Canvas.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,21 @@ Phaser.Canvas = {
200200

201201
},
202202

203+
/**
204+
* Removes the given canvas element from the DOM.
205+
*
206+
* @method Phaser.Canvas.removeFromDOM
207+
* @param {HTMLCanvasElement} canvas - The canvas to be removed from the DOM.
208+
*/
209+
removeFromDOM: function (canvas) {
210+
211+
if (canvas.parentNode)
212+
{
213+
canvas.parentNode.removeChild(canvas);
214+
}
215+
216+
},
217+
203218
/**
204219
* Sets the transform of the given canvas to the matrix values provided.
205220
*

0 commit comments

Comments
 (0)