Skip to content

Commit 1ba1255

Browse files
committed
catch missing plugin require in examples
1 parent 2ade78f commit 1ba1255

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

examples/avalanche.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
var Example = Example || {};
22

33
Example.avalanche = function() {
4-
if (typeof MatterWrap !== 'undefined') {
5-
// either use by name from plugin registry (Browser global)
6-
Matter.use('matter-wrap');
7-
} else {
8-
// or require and use the plugin directly (Node.js, Webpack etc.)
9-
Matter.use(require('matter-wrap'));
4+
try {
5+
if (typeof MatterWrap !== 'undefined') {
6+
// either use by name from plugin registry (Browser global)
7+
Matter.use('matter-wrap');
8+
} else {
9+
// or require and use the plugin directly (Node.js, Webpack etc.)
10+
Matter.use(require('matter-wrap'));
11+
}
12+
} catch (e) {
13+
// could not require the plugin or install needed
1014
}
1115

1216
var Engine = Matter.Engine,

examples/ballPool.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
var Example = Example || {};
22

33
Example.ballPool = function() {
4-
if (typeof MatterWrap !== 'undefined') {
5-
// either use by name from plugin registry (Browser global)
6-
Matter.use('matter-wrap');
7-
} else {
8-
// or require and use the plugin directly (Node.js, Webpack etc.)
9-
Matter.use(require('matter-wrap'));
4+
try {
5+
if (typeof MatterWrap !== 'undefined') {
6+
// either use by name from plugin registry (Browser global)
7+
Matter.use('matter-wrap');
8+
} else {
9+
// or require and use the plugin directly (Node.js, Webpack etc.)
10+
Matter.use(require('matter-wrap'));
11+
}
12+
} catch (e) {
13+
// could not require the plugin or install needed
1014
}
1115

1216
var Engine = Matter.Engine,

0 commit comments

Comments
 (0)