A Vue component of a slot machine, made with an HTML5 canvas, RWD.
- Use
npm
oryarn
download@puckwang/vue-slot-machine
.
npm install @puckwang/vue-slot-machine
// or
yarn add @puckwang/vue-slot-machine
- Registered component. Then register the plugin to globally install all components:
import SlotMachine from '@puckwang/vue-slot-machine';
Vue.use(SlotMachine);
Or, import components individually for local registration:
import {SlotMachine} from '@puckwang/vue-slot-machine';
export default {
components: { "slot-machine": SlotMachine }
}
<div id="app">
<div>
<slot-machine></slot-machine>
</div>
</div>
<script src="https://unpkg.com/@puckwang/vue-slot-machine@latest"></script>
<script>
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
},
components: { "slot-machine": VueSlotMachine.SlotMachine }
})
</script>
<template>
<slot-machine
:list="list"
:trigger="trigger"
:height="300"
:width="300"
@onComplete="onComplete">
</slot-machine>
</template>
<script>
export default {
data() {
return {
list: [
{text: '1', color: '#668CFF'},
{text: '2', color: '#FF6666'},
{text: '3', color: '#B366FF'},
],
trigger: null,
};
},
methods: {
start() { // Trigger to let the machine start
this.trigger = new Date();
},
onComplete(data) { // Run complete callback
console.log(data);
}
}
}
</script>
- Type: Object[]
- Description: A list of gift object.
- Default: 0~9
- Type: Date
- Description: Use to trigger to let the machine start.
- Default: null
- Type: Integer
- Description: Specify the index the result.
- Default: -1
- Type: Date
- Description: Width of canvas.
- Default: 300
- Type: Date
- Description: Height of canvas.
- Default: 300
- Type: Boolean
- Description: Responsive Canvas, width and height will be filled parent element, it's according to the set ratio (height / width).
- Default: false
- Type: String
- Description: Text of the gift.
- Required
- Type: ColorHex
- Description: Color of the gift.
- Default: #000 (Black)
Please open an issue for support.
Please contribute using Github Flow. Create a branch, add commits, and open a pull request.