Skip to content
This repository

[#1317] Fixed issue where trackevents were not being removed properly wh... #192

Open
wants to merge 1 commit into from

3 participants

David Seifried Rick Waldron ScottDowne
David Seifried
Collaborator

...en calling removePlugin

ScottDowne ScottDowne commented on the diff August 30, 2012
popcorn.js
((19 lines not shown))
1834 1834
 
1835 1835
         // update for loop if something removed, but keep checking
1836  
-        idx--; sl--;
1837  
-        if ( obj.data.trackEvents.startIndex <= idx ) {
  1836
+        if ( obj.data.trackEvents.startIndex > sl ) {
2
ScottDowne Collaborator

Are you sure this should be reversed?

I worry this was here to make sure if the currently indexed track event is removed, we are not forced to scrub forward and back to be able to get the proper index.

ScottDowne Collaborator

So yes, I am pretty sure you want to keep the old code, being <=

You also probably want to make sure it never goes below 0. If it currently is 0, and you're removing the first three track events, you want to keep it at 0, otherwise, you want to go back one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Rick Waldron
Collaborator

Need some tests to prove it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 30, 2012
David Seifried [#1317] Fixed issue where trackevents were not being removed properly…
… when calling removePlugin
99d62fa
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 11 additions and 16 deletions. Show diff stats Hide diff stats

  1. 27  popcorn.js
27  popcorn.js
@@ -1821,20 +1821,19 @@
1821 1821
     var byStart = obj.data.trackEvents.byStart,
1822 1822
         byEnd = obj.data.trackEvents.byEnd,
1823 1823
         animating = obj.data.trackEvents.animating,
1824  
-        idx, sl;
  1824
+        sl;
1825 1825
 
1826 1826
     // remove all trackEvents
1827  
-    for ( idx = 0, sl = byStart.length; idx < sl; idx++ ) {
  1827
+    for ( sl = byStart.length; sl > 0; sl-- ) {
1828 1828
 
1829  
-      if ( byStart[ idx ] && byStart[ idx ]._natives && byStart[ idx ]._natives.type === name ) {
  1829
+      if ( byStart[ sl ] && byStart[ sl ]._natives && byStart[ sl ]._natives.type === name ) {
1830 1830
 
1831  
-        byStart[ idx ]._natives._teardown && byStart[ idx ]._natives._teardown.call( obj, byStart[ idx ] );
  1831
+        byStart[ sl ]._natives._teardown && byStart[ sl ]._natives._teardown.call( obj, byStart[ sl ] );
1832 1832
 
1833  
-        byStart.splice( idx, 1 );
  1833
+        byStart.splice( sl, 1 );
1834 1834
 
1835 1835
         // update for loop if something removed, but keep checking
1836  
-        idx--; sl--;
1837  
-        if ( obj.data.trackEvents.startIndex <= idx ) {
  1836
+        if ( obj.data.trackEvents.startIndex > sl ) {
1838 1837
           obj.data.trackEvents.startIndex--;
1839 1838
           obj.data.trackEvents.endIndex--;
1840 1839
         }
@@ -1842,24 +1841,20 @@
1842 1841
 
1843 1842
       // clean any remaining references in the end index
1844 1843
       // we do this seperate from the above check because they might not be in the same order
1845  
-      if ( byEnd[ idx ] && byEnd[ idx ]._natives && byEnd[ idx ]._natives.type === name ) {
  1844
+      if ( byEnd[ sl ] && byEnd[ sl ]._natives && byEnd[ sl ]._natives.type === name ) {
1846 1845
 
1847  
-        byEnd.splice( idx, 1 );
  1846
+        byEnd.splice( sl, 1 );
1848 1847
       }
1849 1848
     }
1850 1849
 
1851 1850
     //remove all animating events
1852  
-    for ( idx = 0, sl = animating.length; idx < sl; idx++ ) {
  1851
+    for ( sl = animating.length; sl > 0; sl-- ) {
1853 1852
 
1854  
-      if ( animating[ idx ] && animating[ idx ]._natives && animating[ idx ]._natives.type === name ) {
  1853
+      if ( animating[ sl ] && animating[ sl ]._natives && animating[ sl ]._natives.type === name ) {
1855 1854
 
1856  
-        animating.splice( idx, 1 );
1857  
-
1858  
-        // update for loop if something removed, but keep checking
1859  
-        idx--; sl--;
  1855
+        animating.splice( sl, 1 );
1860 1856
       }
1861 1857
     }
1862  
-
1863 1858
   };
1864 1859
 
1865 1860
   Popcorn.compositions = {};
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.