nipplejs
nipplejs copied to clipboard
[FEAT] Vue /Nuxt integration example?
It would be very helpful to see an example where this library is integrated in a vue/nuxt enviroment.
I ended up injecting the nipple.min.js file via plugins It works but I'm not sure if this is the way to go :\
I'm using it with Quasar something like this: (in SPA mode; with Nuxt in Universal mode you'd have to wrap the mounted in a
if (process.browser) { }
block, but the same setup should work without plugins (although plugins work well too; it's really all a matter of whether you want the component to be global or not):
<template>
<div class="virtual--gamepad">
</div>
</template>
<script>
import nipplejs from 'nipplejs'
export default {
name: 'VirtualGamepad',
mounted () {
// eslint-disable-next-line no-unused-vars
const staticGamepad = nipplejs.create({
zone: document.querySelector('.virtual--gamepad'),
mode: 'static',
position: { left: '50%', top: '50%' },
color: '#c9c3b2',
threshold: 0.25,
fadeTime: 400,
maxNumberOfNipples: 1
})
}
}
</script>