Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Open
wants to merge 1 commit into from

3 participants

@dseif
Owner

...en calling removePlugin

@ScottDowne ScottDowne commented on the diff
popcorn.js
((19 lines not shown))
// update for loop if something removed, but keep checking
- idx--; sl--;
- if ( obj.data.trackEvents.startIndex <= idx ) {
+ if ( obj.data.trackEvents.startIndex > sl ) {
@ScottDowne Owner

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 Owner

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
@rwaldron
Owner

Need some tests to prove it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 30, 2012
  1. @dseif

    [#1317] Fixed issue where trackevents were not being removed properly…

    dseif authored
    … when calling removePlugin
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 16 deletions.
  1. +11 −16 popcorn.js
View
27 popcorn.js
@@ -1821,20 +1821,19 @@
var byStart = obj.data.trackEvents.byStart,
byEnd = obj.data.trackEvents.byEnd,
animating = obj.data.trackEvents.animating,
- idx, sl;
+ sl;
// remove all trackEvents
- for ( idx = 0, sl = byStart.length; idx < sl; idx++ ) {
+ for ( sl = byStart.length; sl > 0; sl-- ) {
- if ( byStart[ idx ] && byStart[ idx ]._natives && byStart[ idx ]._natives.type === name ) {
+ if ( byStart[ sl ] && byStart[ sl ]._natives && byStart[ sl ]._natives.type === name ) {
- byStart[ idx ]._natives._teardown && byStart[ idx ]._natives._teardown.call( obj, byStart[ idx ] );
+ byStart[ sl ]._natives._teardown && byStart[ sl ]._natives._teardown.call( obj, byStart[ sl ] );
- byStart.splice( idx, 1 );
+ byStart.splice( sl, 1 );
// update for loop if something removed, but keep checking
- idx--; sl--;
- if ( obj.data.trackEvents.startIndex <= idx ) {
+ if ( obj.data.trackEvents.startIndex > sl ) {
@ScottDowne Owner

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 Owner

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
obj.data.trackEvents.startIndex--;
obj.data.trackEvents.endIndex--;
}
@@ -1842,24 +1841,20 @@
// clean any remaining references in the end index
// we do this seperate from the above check because they might not be in the same order
- if ( byEnd[ idx ] && byEnd[ idx ]._natives && byEnd[ idx ]._natives.type === name ) {
+ if ( byEnd[ sl ] && byEnd[ sl ]._natives && byEnd[ sl ]._natives.type === name ) {
- byEnd.splice( idx, 1 );
+ byEnd.splice( sl, 1 );
}
}
//remove all animating events
- for ( idx = 0, sl = animating.length; idx < sl; idx++ ) {
+ for ( sl = animating.length; sl > 0; sl-- ) {
- if ( animating[ idx ] && animating[ idx ]._natives && animating[ idx ]._natives.type === name ) {
+ if ( animating[ sl ] && animating[ sl ]._natives && animating[ sl ]._natives.type === name ) {
- animating.splice( idx, 1 );
-
- // update for loop if something removed, but keep checking
- idx--; sl--;
+ animating.splice( sl, 1 );
}
}
-
};
Popcorn.compositions = {};
Something went wrong with that request. Please try again.