From f0a7ccf50e3234af61e2dbc1649797c88266570d Mon Sep 17 00:00:00 2001 From: Robert Peek Date: Tue, 23 Jul 2019 10:16:06 +0100 Subject: [PATCH] Fixes #32 --- README.md | 2 +- bower.json | 2 +- js/adapt-flipcard-audio.js | 35 +++++++++++++++++------------------ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 7818cbc..f2ecc92 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bower.json b/bower.json index f47e766..701215a 100644 --- a/bower.json +++ b/bower.json @@ -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", diff --git a/js/adapt-flipcard-audio.js b/js/adapt-flipcard-audio.js index c705389..4fdaaf4 100644 --- a/js/adapt-flipcard-audio.js +++ b/js/adapt-flipcard-audio.js @@ -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'); @@ -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. @@ -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"); @@ -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) {