This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
<script>
|
||||
import {Howl} from 'howler'
|
||||
import axios from 'axios'
|
||||
import _ from 'lodash'
|
||||
|
||||
export default {
|
||||
name: 'Home',
|
||||
@@ -30,7 +31,8 @@ export default {
|
||||
soundsLoaded: 0,
|
||||
errorText: null,
|
||||
columnWidth: 6,
|
||||
fullscreenRequested: false
|
||||
sequence: [],
|
||||
sequenceCleanerTimeout: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -39,9 +41,14 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
play(sampleId) {
|
||||
patternMagic(sampleId) {
|
||||
this.sequence.push(sampleId)
|
||||
|
||||
if (!this.fullscreenRequested) {
|
||||
if (this.sequence.length > 4) {
|
||||
this.sequence.shift() // removes the first element from an array
|
||||
}
|
||||
|
||||
if (_.isEqual(this.sequence, [0, 1, 3, 2])) {
|
||||
const elem = document.documentElement
|
||||
|
||||
if (elem.requestFullscreen) {
|
||||
@@ -52,7 +59,38 @@ export default {
|
||||
elem.msRequestFullscreen();
|
||||
}
|
||||
|
||||
this.fullscreenRequested = true
|
||||
this.sequence = []
|
||||
}
|
||||
|
||||
if (_.isEqual(this.sequence, [0, 3, 3, 0])) {
|
||||
location.reload()
|
||||
this.sequence = []
|
||||
}
|
||||
|
||||
if (_.isEqual(this.sequence, [0, 3, 1, 1])) {
|
||||
this.bgSound.stop()
|
||||
this.availableSounds[this.nowPlaying].howl.stop()
|
||||
this.nowPlaying = -1
|
||||
this.sequence = []
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set timer to clear sequence
|
||||
if (this.sequenceCleanerTimeout !== null) {
|
||||
clearTimeout(this.sequenceCleanerTimeout)
|
||||
}
|
||||
this.sequenceCleanerTimeout = setTimeout(() => {
|
||||
this.sequence = []
|
||||
this.sequenceCleanerTimeout = null
|
||||
},3000)
|
||||
|
||||
return false;
|
||||
},
|
||||
play(sampleId) {
|
||||
const prevent = this.patternMagic(sampleId)
|
||||
|
||||
if (prevent) {
|
||||
return;
|
||||
}
|
||||
|
||||
const sample = this.availableSounds[sampleId].howl
|
||||
|
||||
Reference in New Issue
Block a user