mobile screen keep rotation when button pressed

61 views Asked by At

see http://liveweave.com/0POip0

i want when user keeps "rotate" text pressed the group object keeps on rotation ? as soon as user removes touch press stop rotationg

$('#rotate').on({
    'mousedown touchstart click': function () {
         var x=setInterval(function () {group.setAngle(group.getAngle()+30);canvas.renderAll();}, 3000);
        return false;
    },
    'mouseup touchend': function () {
      clearInterval(x);
    }
});

getting error Uncaught ReferenceError: x is not defined

2

There are 2 answers

2
NIkhil Reddy Ramolla On
$('#rotate').on({
    'mousedown touchstart click': function () {
        var x=setInterval(function () {group.setAngle(group.getAngle()+30);canvas.renderAll();}, 3000);
        return false;
    },
    'mouseup touchend': function () {
        clearInterval(x);``
    }
});
0
mydeve On

solve need to initialize value of var x

var x=null;
$('#rotate').on({
    'mousedown touchstart click': function () {
         var x=setInterval(function () {group.setAngle(group.getAngle()+30);canvas.renderAll();}, 3000);
        return false;
    },
    'mouseup touchend': function () {
      clearInterval(x);
    }
});