I have a constructor:
function Domino() {
var self = this;
this.myElement = $("#smth");
this.rotation = 0;
this.rotateFor = function (deg, scl) {
this.rotation += deg;
this.scale = scl;
this.myElement.find(".domino-view").css({
transform: "rotate(" + self.rotation + "deg) scale(" + self.scale + ")"
});
};
I want to set timeout on rotateFor
. I tried this:
this.rotateFor = function (deg, scl) {
this.rotation += deg;
this.scale = scl;
this.myElement.find(".domino-view").css({
transform: "rotate(" + self.rotation + "deg) scale(" + self.scale + ")"
});
}
this.start = function(){
self.timeout = setTimeout(function(){this.rotateFor()}, 5000)
}
Then I call it like this: something.start()
, but it still does not work. How can I set timeout in this constructor?