Skip to content

Commit

Permalink
Fixes #32
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertPeek committed Jul 23, 2019
1 parent c46fd2b commit f0a7ccf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The attributes listed below are used in *components.json* to configure **Flip ca
No known limitations.

----------------------------
**Version number:** 2.0.22
**Version number:** 2.0.23
**Framework versions:** 2+
**Author / maintainer:** Deltanet with [contributors](https://github.com/deltanet/adapt-flipcard-audio/graphs/contributors)
**Accessibility support:** yes
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "adapt-flipcard-audio",
"version": "2.0.22",
"version": "2.0.23",
"framework": ">=2",
"homepage": "https://github.com/deltanet/adapt-flipcard-audio",
"issues": "https://github.com/deltanet/adapt-flipcard-audio/issues",
Expand Down
35 changes: 17 additions & 18 deletions js/adapt-flipcard-audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ define([
onClickFlipItem: function(event) {
if (event && event.preventDefault) event.preventDefault();

///// Audio /////
if (Adapt.audio && this.model.has('_audio') && this.model.get('_audio')._isEnabled && Adapt.audio.audioClip[this.model.get('_audio')._channel].status==1) {
Adapt.trigger('audio:pauseAudio', this.model.get('_audio')._channel);
}
///// End of Audio /////

var $selectedElement = $(event.currentTarget);

var flipType = this.model.get('_flipType');
Expand All @@ -167,14 +173,8 @@ define([
} else if (flipType === 'singleFlip') {
this.performSingleFlip($selectedElement);
}
this.resizeHeights();

///// Audio /////
if (!Adapt.audio) return;
if (this.model.has('_audio') && this.model.get('_audio')._isEnabled && Adapt.audio.audioClip[this.model.get('_audio')._channel].status==1) {
Adapt.trigger('audio:pauseAudio', this.model.get('_audio')._channel);
}
///// End of Audio /////
this.resizeHeights();
},

// This function will be responsible to perform All flip on flipcard where all cards can flip and stay in the flipped state.
Expand Down Expand Up @@ -226,6 +226,16 @@ define([
}
this.itemFlipped[index] = true;

///// Audio /////
var item = this.model.get('_items')[index];
if (Adapt.audio && this.model.has('_audio') && this.model.get('_audio')._isEnabled && Adapt.audio.audioClip[this.model.get('_audio')._channel].status==1) {
// Reset onscreen id
Adapt.audio.audioClip[this.model.get('_audio')._channel].onscreenID = "";
// Trigger audio
Adapt.trigger('audio:playAudio', item._audio.src, this.model.get('_id'), this.model.get('_audio')._channel);
}
///// End of Audio /////

this.setVisited(index);
$item.addClass("visited");

Expand All @@ -237,17 +247,6 @@ define([
$itemTitle.a11y_focus();
}, 500);

///// Audio /////
if (!Adapt.audio) return;
var item = this.model.get('_items')[index];
if (this.model.has('_audio') && this.model.get('_audio')._isEnabled && Adapt.audio.audioClip[this.model.get('_audio')._channel].status==1) {
// Reset onscreen id
Adapt.audio.audioClip[this.model.get('_audio')._channel].onscreenID = "";
// Trigger audio
Adapt.trigger('audio:playAudio', item._audio.src, this.model.get('_id'), this.model.get('_audio')._channel);
}
///// End of Audio /////

} else {
// Flip it back
if (Modernizr.csstransforms3d) {
Expand Down

0 comments on commit f0a7ccf

Please sign in to comment.