Skip to content

Commit

Permalink
fix: issue where deleting frames did not reindex them properly
Browse files Browse the repository at this point in the history
  • Loading branch information
doubleactii committed Sep 26, 2024
1 parent 781ee7d commit af3e36a
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 38 deletions.
2 changes: 1 addition & 1 deletion docs/Frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 15:51:20 GMT-0500 (Central Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 23:52:47 GMT-0500 (Central Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
56 changes: 28 additions & 28 deletions docs/Icon.html
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ <h4 class="name" id="addFrame"><span class="type-signature"></span>addFrame<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line325">line 325</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line334">line 334</a>
</li></ul></dd>


Expand Down Expand Up @@ -425,7 +425,7 @@ <h4 class="name" id="addState"><span class="type-signature"></span>addState<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line458">line 458</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line469">line 469</a>
</li></ul></dd>


Expand Down Expand Up @@ -588,7 +588,7 @@ <h4 class="name" id="getDataURL"><span class="type-signature"></span>getDataURL<

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line263">line 263</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line272">line 272</a>
</li></ul></dd>


Expand Down Expand Up @@ -696,7 +696,7 @@ <h4 class="name" id="getDelay"><span class="type-signature"></span>getDelay<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line283">line 283</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line292">line 292</a>
</li></ul></dd>


Expand Down Expand Up @@ -804,7 +804,7 @@ <h4 class="name" id="getFrame"><span class="type-signature"></span>getFrame<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line434">line 434</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line445">line 445</a>
</li></ul></dd>


Expand Down Expand Up @@ -967,7 +967,7 @@ <h4 class="name" id="getFrames"><span class="type-signature"></span>getFrames<sp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line441">line 441</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line452">line 452</a>
</li></ul></dd>


Expand Down Expand Up @@ -1075,7 +1075,7 @@ <h4 class="name" id="getHeight"><span class="type-signature"></span>getHeight<sp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line236">line 236</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line245">line 245</a>
</li></ul></dd>


Expand Down Expand Up @@ -1183,7 +1183,7 @@ <h4 class="name" id="getId"><span class="type-signature"></span>getId<span class

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line135">line 135</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line144">line 144</a>
</li></ul></dd>


Expand Down Expand Up @@ -1291,7 +1291,7 @@ <h4 class="name" id="getName"><span class="type-signature"></span>getName<span c

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line303">line 303</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line312">line 312</a>
</li></ul></dd>


Expand Down Expand Up @@ -1399,7 +1399,7 @@ <h4 class="name" id="getParent"><span class="type-signature"></span>getParent<sp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line149">line 149</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line158">line 158</a>
</li></ul></dd>


Expand Down Expand Up @@ -1510,7 +1510,7 @@ <h4 class="name" id="getSize"><span class="type-signature"></span>getSize<span c

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line243">line 243</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line252">line 252</a>
</li></ul></dd>


Expand Down Expand Up @@ -1618,7 +1618,7 @@ <h4 class="name" id="getState"><span class="type-signature"></span>getState<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line544">line 544</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line555">line 555</a>
</li></ul></dd>


Expand Down Expand Up @@ -1778,7 +1778,7 @@ <h4 class="name" id="getStates"><span class="type-signature"></span>getStates<sp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line572">line 572</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line583">line 583</a>
</li></ul></dd>


Expand Down Expand Up @@ -1886,7 +1886,7 @@ <h4 class="name" id="getVyi"><span class="type-signature"></span>getVyi<span cla

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line142">line 142</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line151">line 151</a>
</li></ul></dd>


Expand Down Expand Up @@ -1994,7 +1994,7 @@ <h4 class="name" id="getWidth"><span class="type-signature"></span>getWidth<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line229">line 229</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line238">line 238</a>
</li></ul></dd>


Expand Down Expand Up @@ -2102,7 +2102,7 @@ <h4 class="name" id="parse"><span class="type-signature"></span>parse<span class

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line156">line 156</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line165">line 165</a>
</li></ul></dd>


Expand Down Expand Up @@ -2237,7 +2237,7 @@ <h4 class="name" id="removeFrame"><span class="type-signature"></span>removeFram

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line358">line 358</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line366">line 366</a>
</li></ul></dd>


Expand Down Expand Up @@ -2397,7 +2397,7 @@ <h4 class="name" id="removeFrameByIndex"><span class="type-signature"></span>rem

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line373">line 373</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line381">line 381</a>
</li></ul></dd>


Expand Down Expand Up @@ -2557,7 +2557,7 @@ <h4 class="name" id="removeState"><span class="type-signature"></span>removeStat

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line511">line 511</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line522">line 522</a>
</li></ul></dd>


Expand Down Expand Up @@ -2717,7 +2717,7 @@ <h4 class="name" id="removeStateById"><span class="type-signature"></span>remove

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line534">line 534</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line545">line 545</a>
</li></ul></dd>


Expand Down Expand Up @@ -2877,7 +2877,7 @@ <h4 class="name" id="removeStateByName"><span class="type-signature"></span>remo

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line524">line 524</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line535">line 535</a>
</li></ul></dd>


Expand Down Expand Up @@ -3037,7 +3037,7 @@ <h4 class="name" id="rename"><span class="type-signature"></span>rename<span cla

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line291">line 291</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line300">line 300</a>
</li></ul></dd>


Expand Down Expand Up @@ -3197,7 +3197,7 @@ <h4 class="name" id="reorderFrame"><span class="type-signature"></span>reorderFr

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line396">line 396</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line407">line 407</a>
</li></ul></dd>


Expand Down Expand Up @@ -3383,7 +3383,7 @@ <h4 class="name" id="setAllFrameDelays"><span class="type-signature"></span>setA

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line311">line 311</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line320">line 320</a>
</li></ul></dd>


Expand Down Expand Up @@ -3543,7 +3543,7 @@ <h4 class="name" id="setDataURL"><span class="type-signature"></span>setDataURL<

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line251">line 251</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line260">line 260</a>
</li></ul></dd>


Expand Down Expand Up @@ -3703,7 +3703,7 @@ <h4 class="name" id="setDelay"><span class="type-signature"></span>setDelay<span

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line271">line 271</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line280">line 280</a>
</li></ul></dd>


Expand Down Expand Up @@ -3863,7 +3863,7 @@ <h4 class="name" id="setSize"><span class="type-signature"></span>setSize<span c

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line217">line 217</a>
<a href="icon.mjs.html">icon.mjs</a>, <a href="icon.mjs.html#line226">line 226</a>
</li></ul></dd>


Expand Down Expand Up @@ -4018,7 +4018,7 @@ <h5>Returns:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 15:51:20 GMT-0500 (Central Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 23:52:47 GMT-0500 (Central Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/VYI.html
Original file line number Diff line number Diff line change
Expand Up @@ -1947,7 +1947,7 @@ <h5>Parameters:</h5>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 15:51:20 GMT-0500 (Central Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 23:52:47 GMT-0500 (Central Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/frame.mjs.html
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ <h1 class="page-title">frame.mjs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 15:51:20 GMT-0500 (Central Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 23:52:47 GMT-0500 (Central Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
17 changes: 14 additions & 3 deletions docs/icon.mjs.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,15 @@ <h1 class="page-title">icon.mjs</h1>

if (pVyi instanceof VYI) {
this.vyi = pVyi;

const states = this.getStates();
const frames = this.getFrames();
states.forEach((pState) => {
pState.setParent(this);
pState.setVyi(this.vyi);
});
frames.forEach((pFrame) => pFrame.setParent(this));

}
}
/**
Expand Down Expand Up @@ -385,7 +394,6 @@ <h1 class="page-title">icon.mjs</h1>
}

frame.setParent(this);
// We store this frame under its index in the Map 0-1
this.frames.set(this.frames.size, frame);
this.indexFrames();

Expand Down Expand Up @@ -421,8 +429,11 @@ <h1 class="page-title">icon.mjs</h1>
* @private
*/
indexFrames() {
this.getFrames().forEach((pFrame, pIndex) => {
const frames = this.getFrames();
this.frames.clear();
frames.forEach((pFrame, pIndex) => {
pFrame.index = pIndex;
this.frames.set(pIndex, pFrame);
});
}
/**
Expand Down Expand Up @@ -677,7 +688,7 @@ <h1 class="page-title">icon.mjs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 15:51:20 GMT-0500 (Central Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 23:52:47 GMT-0500 (Central Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h3>Global Dependency</h3>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 15:51:20 GMT-0500 (Central Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 23:52:47 GMT-0500 (Central Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/vyi.mjs.html
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ <h1 class="page-title">vyi.mjs</h1>
<br class="clear">

<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 15:51:20 GMT-0500 (Central Daylight Time) using the Minami theme.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Wed Sep 25 2024 23:52:47 GMT-0500 (Central Daylight Time) using the Minami theme.
</footer>

<script>prettyPrint();</script>
Expand Down
15 changes: 13 additions & 2 deletions src/icon.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ export class Icon {

if (pVyi instanceof VYI) {
this.vyi = pVyi;

const states = this.getStates();
const frames = this.getFrames();
states.forEach((pState) => {
pState.setParent(this);
pState.setVyi(this.vyi);
});
frames.forEach((pFrame) => pFrame.setParent(this));

}
}
/**
Expand Down Expand Up @@ -344,7 +353,6 @@ export class Icon {
}

frame.setParent(this);
// We store this frame under its index in the Map 0-1
this.frames.set(this.frames.size, frame);
this.indexFrames();

Expand Down Expand Up @@ -380,8 +388,11 @@ export class Icon {
* @private
*/
indexFrames() {
this.getFrames().forEach((pFrame, pIndex) => {
const frames = this.getFrames();
this.frames.clear();
frames.forEach((pFrame, pIndex) => {
pFrame.index = pIndex;
this.frames.set(pIndex, pFrame);
});
}
/**
Expand Down

0 comments on commit af3e36a

Please sign in to comment.