Skip to content

Commit

Permalink
Fixing .clear() after performance tunning
Browse files Browse the repository at this point in the history
  • Loading branch information
Agezao committed Aug 9, 2018
1 parent b20bfc5 commit cd783d9
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
12 changes: 8 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,15 @@ window.ConfettiGenerator = function(params) {
//////////////
// Clean actual state
var _clear = function() {
ctx.clearRect(0, 0, cv.width, cv.height);
var w = cv.width;
cv.width = 1;
cv.width = w;
appstate.animate = false;
clearInterval(appstate.interval);

requestAnimationFrame(function() {
ctx.clearRect(0, 0, cv.width, cv.height);
var w = cv.width;
cv.width = 1;
cv.width = w;
});
}

//////////////
Expand Down
2 changes: 1 addition & 1 deletion dist/index.min.js

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

2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ <h2>Settings</h2>
<div>
<br />
<input type="button" onclick="app.render()" id="btnRender" value="Render" />

<input type="button" onclick="app.clear()" id="btnClear" value="Clear" />
</div>
</form>
<div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "confetti-js",
"version": "0.0.12",
"version": "0.0.13",
"description": "Easily Generate random confetti for your above-the-fold content",
"main": "dist/index.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions site/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ body {
background-color: #fff;
font-family: 'Lato', sans-serif;
}
body {
overflow-x: hidden;
}
div {
box-sizing: border-box;
}
Expand Down
5 changes: 5 additions & 0 deletions site/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,13 @@ var AppClass = function() {
render();
};

var clear = function() {
confetti.clear();
}

return {
start: start,
clear: clear,
render: render
};
}
Expand Down

0 comments on commit cd783d9

Please sign in to comment.