Skip to content

Commit

Permalink
refactor: progressbar.js -> progressbar.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
andretchen0 committed Aug 6, 2023
1 parent 16ef54e commit 09a28c2
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/ui/progressbar.js → src/ui/progressbar.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
import * as $j from 'jquery';

type ProgressBarOptions = {
height: number;
width: number;
color: string;
$bar: any;
};

export class ProgressBar {
constructor(opts) {
const defaultOpts = {
$bar: any;
$preview: any;
$current: any;
width: number;
height: number;
color: string;

constructor(opts: Partial<ProgressBarOptions>) {
const defaultOpts: ProgressBarOptions = {
height: 316,
width: 7,
color: 'red',
$bar: undefined,
};

opts = $j.extend(defaultOpts, opts);
opts = Object.assign({}, defaultOpts, opts);
$j.extend(this, opts);

this.$bar.append('<div class="previewbar"></div>');
Expand All @@ -24,7 +38,7 @@ export class ProgressBar {
/**
* @param{number} percentage - Size between 0 and 1
*/
setSize(percentage) {
setSize(percentage: number) {
this.$bar.css({
width: this.width,
height: this.height * percentage,
Expand All @@ -43,7 +57,7 @@ export class ProgressBar {
/**
* @param{number} percentage - size between 0 and 1
*/
animSize(percentage) {
animSize(percentage: number) {
this.$bar.transition(
{
queue: false,
Expand All @@ -70,7 +84,7 @@ export class ProgressBar {
/**
* @param{number} percentage - size between 0 and 1
*/
previewSize(percentage) {
previewSize(percentage: number) {
this.$preview.css(
{
width: this.width,
Expand Down

0 comments on commit 09a28c2

Please sign in to comment.