|
1 | 1 | var registerComponent = require('../core/component').registerComponent; |
2 | 2 | var debug = require('../utils/debug'); |
3 | | -var bind = require('../utils/bind'); |
4 | 3 | var THREE = require('../lib/three'); |
5 | 4 |
|
6 | 5 | var warn = debug('components:sound:warn'); |
@@ -31,7 +30,9 @@ module.exports.Component = registerComponent('sound', { |
31 | 30 | this.pool = new THREE.Group(); |
32 | 31 | this.loaded = false; |
33 | 32 | this.mustPlay = false; |
34 | | - this.playSound = bind(this.playSound, this); |
| 33 | + |
| 34 | + // Don't pass evt because playSound takes a function as parameter. |
| 35 | + this.playSoundBound = () => { this.playSound(); }; |
35 | 36 | }, |
36 | 37 |
|
37 | 38 | update: function (oldData) { |
@@ -119,12 +120,12 @@ module.exports.Component = registerComponent('sound', { |
119 | 120 | */ |
120 | 121 | updateEventListener: function (oldEvt) { |
121 | 122 | var el = this.el; |
122 | | - if (oldEvt) { el.removeEventListener(oldEvt, this.playSound); } |
123 | | - el.addEventListener(this.data.on, this.playSound); |
| 123 | + if (oldEvt) { el.removeEventListener(oldEvt, this.playSoundBound); } |
| 124 | + el.addEventListener(this.data.on, this.playSoundBound); |
124 | 125 | }, |
125 | 126 |
|
126 | 127 | removeEventListener: function () { |
127 | | - this.el.removeEventListener(this.data.on, this.playSound); |
| 128 | + this.el.removeEventListener(this.data.on, this.playSoundBound); |
128 | 129 | }, |
129 | 130 |
|
130 | 131 | /** |
|
0 commit comments