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

Issue in drawing from Right to Left or Bottom to top #15

Closed sanjeevrajput01 closed 8 years ago

sanjeevrajput01 commented 8 years ago

Issue in drawing from Right to LEFT or Bottom to top. Library does not covers all points. it skipes some points in reverse directions.

image

sanjeevrajput01 commented 8 years ago

I have done some changes in this library. Please change in while loop. and try this.

while (((iDiff == 0 && jDiff > 1) || (jDiff == 0 && iDiff > 1) || (jDiff == iDiff && jDiff > 1)) && !(jp == posObj.j && ip == posObj.i)) { var ipTemp = posObj.i - ip; var jpTemp = posObj.j - jp; if(ipTemp < 0){ ip = iDiff ? Math.max(posObj.i, ip) - 1 : ip; }else{ ip = iDiff ? Math.min(posObj.i, ip) + 1 : ip; } if(jpTemp < 0){ jp = jDiff ? Math.max(posObj.j, jp) - 1 : jp; }else{ jp = jDiff ? Math.min(posObj.j, jp) + 1 : jp; } iDiff = Math.abs(posObj.i - ip); jDiff = Math.abs(posObj.j - jp);

                        var nextIdx = (jp - 1) * iObj.option.matrix[1] + ip,
                            nextPattId = iObj.mapperFunc(nextIdx) || nextIdx;

                        if (patternAry.indexOf(nextPattId) == -1) {
                            $(li[nextIdx - 1]).addClass('hovered');
                            //push pattern on array
                            patternAry.push(nextPattId);
                        }
                    }``
s-yadav commented 8 years ago

@sanjeevrajput01 Thanks for pointing it out. Fixed in version 1.0.1