chanind / hanzi-writer

Chinese character stroke order animations and practice quizzes
https://hanziwriter.org
MIT License
3.44k stars 534 forks source link

Get writer index from callback #314

Open fxpar opened 3 months ago

fxpar commented 3 months ago

Hi, I have multiple writers (looping on all characters in an expression). How to get the index of the current writer when there is a mistake?

writer[i].quiz({
    onMistake: function(strokeData) {
            console.log('currentWriterIndex:' + ???);
    },

I did get something with writer.findIndex(({_char}) => _char === strokeData.character); but it won't work with expressions with repetitive characters like 哥哥 or 弟弟.

Thanks for your help.