Skip to content

Instantly share code, notes, and snippets.

@marcelklehr
Last active May 6, 2020 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelklehr/3842c10255cec688fd1443f012a2c228 to your computer and use it in GitHub Desktop.
Save marcelklehr/3842c10255cec688fd1443f012a2c228 to your computer and use it in GitHub Desktop.
Magpie in Vue.js
<template>
<View @mousemove="mouseMove">
<template slot:content="{nextView, response}">
<div class="top-left" @mouseover="hoverFish">fish</div>
<div class="top-right" @mouseover="hoverMammal">mammal</div>
<button v-if="isButtonVisible" @click="clickButton"></button>
<audio src="example.wav" playing="isPlaying" />
</template>
</view>
</template>
<script>
export default {
async mounted() {
this.mousemovements = []
this.isButtonVisible = false
this.isPlaying = false
this.recordMousemovements = false
await sleep(500)
this.isButtonVisible = true
},
methods: {
clickButton() {
this.isPlaying = true
this.recordMousemovements = true
},
mouseMove(event) {
if (this.recordMousemovements) {
this.mousemovements.push(event)
}
},
hoverFish() {
this.response('fish', this.mousemovements)
this.next()
},
hoverMammal() {
this.response('mammal', this.mousemovements)
this.next()
}
}
}
</script>
<template>
<Experiment>
<View title="Please listen">
<template slot:content="{nextView}">
<img src="example.png" />
<audio autoplay="true" src="example.wav" onDone="nextView"/>
</template>
</View>
<View timeout="500" />
<AudioResponseView />
<View timeout="500" />
<ThankYouView />
</Experiment>
</template>
@marcelklehr
Copy link
Author

This example is non-functional, but serves to show-case a possible programming interface for magpie using Vue.js

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