s-yadav / patternLock

A light weight plugin to simulate android like pattern lock interface for your hybrid app or website.
MIT License
378 stars 141 forks source link

setPattern not working #23

Closed tmTara closed 5 years ago

tmTara commented 7 years ago

Hi, I am trying to set the pattern dynamically but its not working. Could you please provide me an example?

TingChinLin commented 5 years ago

I am using "setPattern" function in react.js, and I find a bug that in the function get parameters (matrix, margin and radius) from privateMap.get(this) is undefined, to fix this bug might get those parameters from option object witch we setting or make sure those parameters has been set in privateMap. In my case i use

const {option } = iObj;
const {matrix=iObj.matrix, margin=iObj.margin, radius=iObj.radius} = option

instead of const { option, matrix, margin, radius } = iObj;

jan-sti commented 5 years ago

Looks like a typo on the rewrite for ES6.

Before rewrite: var iObj = objectHolder[this.token], option = iObj.option, matrix = option.matrix, margin = option.margin, radius = option.radius;

After rewrite: var option = iObj.option, matrix = iObj.matrix, margin = [iObj.margin,] radius = iObj.radius;

I create a pull request for the fix.

29

zquanghoangz commented 5 years ago

Hi Jan-sti,

The setPattern is not working for me. Already have your fix in https://github.com/s-yadav/patternLock/pull/29

this issue is Matrix is undefined. I think because of your change

zquanghoangz commented 5 years ago

I need to change the code to make it work, this is the change

`var option = iObj.option, matrix = iObj.matrix, margin = iObj.margin, radius = iObj.radius;

            if (!matrix && iObj.option.matrix) {
                matrix = iObj.option.matrix;
            }
            if (!margin && iObj.option.margin) {
                margin = iObj.option.margin;
            }
            if (!radius && iObj.option.radius) {
                radius = iObj.option.radius;
            }`