AdamTyler / react-dice-complete

Complete dice rolling functionality and animations
http://adam-tyler.com/react-dice-complete
ISC License
79 stars 26 forks source link

Ability to pre-set dice results when rolling #7

Closed Nedomas closed 5 years ago

Nedomas commented 6 years ago

Implements the ability to pre-set dice results instead of generating random numbers on roll.

This is useful if you do the randomness somewhere else (for example - server).

A simple example would be:

import React, { Component } from 'react'
import ReactDice from 'react-dice-complete'
import 'react-dice-complete/dist/react-dice-complete.css'

export default class Dices extends Component {
  componentDidUpdate() {
    const dices = [5, 3]
    this.reactDice.rollAll(dices)
  }

  render() {
    return (
        <ReactDice
          numDice={2}
          rollDone={() => {}}
          ref={dice => this.reactDice = dice}
        />
    )
  }
}
kali67 commented 5 years ago

Is it possible to merge this in? I would really like to use this feature.

Nedomas commented 5 years ago

@AdamTyler could you merge and release this one?

kali67 commented 5 years ago

@AdamTyler, are you able to merge and release this please? Thanks.

AdamTyler commented 5 years ago

@kali @Nedomas I plan to revisit and revive this repo in the next few days. Will keep you posted

AdamTyler commented 5 years ago

I updated the repo which included removing built files that your PR had conflicts with. I ended up pulling your changes into release v1.2.0. Thanks for the work! Hopefully this fits your needs a little better