Skip to content

Conversation

@lazychip
Copy link
Contributor

@lazychip lazychip commented Mar 6, 2019

Description:
In sound component on sound ended isPlaying is not set to false

sound.onEnded = function () {
    this.isPlaying = false;
    el.emit('sound-ended', self.evtDetail, false);
};

Changes proposed:

  • use self instead of this or change the onEnded callback function to arrow function.
sound.onEnded = function () {
    self.isPlaying = false;
    el.emit('sound-ended', self.evtDetail, false);
};

or

sound.onEnded = () => {
    this.isPlaying = false;
    el.emit('sound-ended', self.evtDetail, false);
};

sound = this.pool.children[i];
sound.onEnded = function () {
this.isPlaying = false;
self.isPlaying = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for whomever does review this from the AFrame team.

Are we explicitly avoiding arrow functions to capture this?

If we are, should we instead be using the bind() helper instead of capturing a "self"? This would make things more consistent. We tend to use bind() for simple functions and any complex function wrappers we instead use self.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, no arrow functions: Not supported in IE 11. As @DigiTec said probably bind a bit cleaner than self.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants