javascript - Pomodoro clock canvas ring not registering -


good evening everyone. i'm having trouble bit of code , have been @ few hours. if take in constructor @ this.drawarc , in prototype, i've logged console couple things. can see this.count logs value, this.drawarc not. obviously, this.minutes , this.toseconds work, or timer wouldn't start, why drawarc not register values?? had this(the status ring) working before placing in constructor, reason, no longer registers values. have attached fiddle.

notes: not complete - have re-run if want enter new value input field. once value has been entered input(the small circle above button) can hover on canvas(the larger circle) view countdown. reason on hover don't want see ticking clock , prefer visual of status ring. ideas??? i've been stuck few hours. thank in advance
https://jsfiddle.net/asthewaterfalls/szn0mch1/9/

function pomodoro(userinput) {     this.minutes = userinput;      this.toseconds = 60 * this.minutes;//seconds - actual     this.cout = this.toseconds; //for timer     this.seconds = 0; //display     this.count = 0; //for status ring      this.circlestart = math.pi * 1.5;     this.drawarc = (2 / this.toseconds) * this.count; }  pomodoro.prototype.statusring = function () {     if(this.count <= this.toseconds) {         dom.canv.beginpath();          dom.canv.arc(125, 125, 121, this.circlestart, math.pi * (1.5 + this.drawarc), false);         dom.canv.stroke();         this.count++;         console.log(this.count, this.drawarc);         const timeout = settimeout(() => this.statusring(), 1000 );     } }; 

i took @ fiddle. 2 small changes got animation blue ring around clock. did not check ratios or angeles.

i made drawarg function, calculating current value argument , this.toseconds max value:

this.drawarc = function(arg){ return (2 / this.toseconds) * arg; }; 

second, calld function in dom.conv.arc():

dom.canv.arc(/*...*/, math.pi * (1.5 + this.drawarc(this.count)), /*...*/); 

here complete example:

function pomodoro(userinput) {     this.minutes = userinput;     this.toseconds = 60 * this.minutes;//seconds - actual     this.cout = this.toseconds; //for timer     this.seconds = 0; //display     this.count = 0; //for status ring      this.circlestart = math.pi * 1.5;     this.drawarc = function(arg){ return (2 / this.toseconds) * arg; }; }  pomodoro.prototype.statusring = function () {     if(this.count <= this.toseconds) {         dom.canv.beginpath();          dom.canv.arc(125, 125, 121, this.circlestart, math.pi * (1.5 + this.drawarc(this.count)), false);         dom.canv.stroke();         this.count++;         console.log(this.count, this.drawarc);         const timeout = settimeout(() => this.statusring(), 1000 );      } }; 

please let me know, if helps ;)


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -