Skip to content

Commit

Permalink
fix calculateSpeed (bleenco#228)
Browse files Browse the repository at this point in the history
  • Loading branch information
osahner authored and jkuri committed Mar 5, 2017
1 parent b074f80 commit db11e48
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/services/ngx-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ export class NgUploaderService {
xhr.upload.onprogress = (e: ProgressEvent) => {
if (e.lengthComputable) {
if (this.opts.calculateSpeed) {
time = new Date().getTime() - time;
const diff = new Date().getTime() - time;
time += diff;
load = e.loaded - load;
speed = load / time * 1000;
speed = load / diff * 1000;
speed = parseInt(<any>speed, 10);
speedHumanized = this.humanizeBytes(speed);
}
Expand Down

0 comments on commit db11e48

Please sign in to comment.