Skip to content

Commit

Permalink
Added support for mobile phones & tablets
Browse files Browse the repository at this point in the history
Possibility to tap & slide to generate enthropy.
  • Loading branch information
4miners committed Nov 9, 2016
1 parent be06351 commit 7d84c24
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ app.directive('entropy', function ($rootScope, $document, $timeout, wallet, util
console.log('entropy', { turns: turns, steps: steps, total: total });

var listener = function listener(ev) {
if (count >= total) {
return false;
}
var distance = Math.sqrt(Math.pow(ev.pageX - last[0], 2) + Math.pow(ev.pageY - last[1], 2));

if (distance > 60) {
Expand Down Expand Up @@ -263,6 +266,7 @@ app.directive('entropy', function ($rootScope, $document, $timeout, wallet, util

if (count >= total) {
$document.unbind('mousemove', listener);
$document.unbind('touchmove');

$timeout(function () {
var hex = $scope.random.tmp.map(function (v) {
Expand Down Expand Up @@ -294,6 +298,13 @@ app.directive('entropy', function ($rootScope, $document, $timeout, wallet, util
$timeout(function () {
return $document.mousemove(listener);
}, 300);
$document.bind('touchmove',function(e){
e.preventDefault();
window.scrollTo(0,document.body.scrollHeight);
$timeout(function () {
return listener(e.originalEvent.touches[0]);
}, 100);
});
}
};

Expand Down

0 comments on commit 7d84c24

Please sign in to comment.