Skip to content

Commit

Permalink
added repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
Cam O'Connell committed Jan 27, 2019
1 parent 705885b commit e94261f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
3 changes: 1 addition & 2 deletions examples/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

let svg = document.querySelector('#logo');
let config = {
strokeWidth: 1,
strokeDash: '2,2'
strokeWidth: 1
};
let animation = new LazyLinePainter(svg, config);
animation.paint();
Expand Down
10 changes: 9 additions & 1 deletion lib/lazy-line-painter-1.9.4.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/lazy-line-painter-1.9.4.js.map

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* https://github.com/camoconnell/lazy-line-painter
* http://www.camoconnell.com
*
* Copyright 2013-2018 Cam O'Connell
* Copyright 2013-2019 Cam O'Connell
* All rights reserved.
*
* Licensed under the MIT license.
Expand Down Expand Up @@ -46,6 +46,7 @@ class LazyLinePainter {
reverse: false,
paused: false,
progress: 0,
repeat: 0,

longestDuration: 0,
log: true,
Expand Down Expand Up @@ -437,7 +438,14 @@ class LazyLinePainter {
this._paint();
});
} else {
this.emit('complete');
if (this.config.repeat > 0) {
this.config.repeat--;
this.paint();
} else if (this.config.repeat === -1) {
this.paint();
} else {
this.emit('complete');
}
}
}

Expand Down

0 comments on commit e94261f

Please sign in to comment.