]> khamidou — GitHub mirrors - popcorn-js.git/commitdiff
Added isDestroyed on a per instance level instead of a Popcorn wide isDestroyed
authorDavid Seifried <david.c.seifried@gmail.com>
Wed, 21 Sep 2011 15:00:11 +0000 (11:00 -0400)
committerDavid Seifried <david.c.seifried@gmail.com>
Wed, 21 Sep 2011 15:00:11 +0000 (11:00 -0400)
popcorn.js

index fe15842fed950f6bf37579a33bb367a736acabce..5d7c0e1b07ae4fae47319d318bfba121c0141400 100644 (file)
@@ -32,7 +32,6 @@
   readyStack = [],
   readyBound = false,
   readyFired = false,
-  isDestroyed = false,
 
   //  Non-public internal data object
   internal = {
 
       this.options = options || {};
 
+      this.isDestroyed = false;
+
       this.data = {
 
         // Allows disabling a plugin per instance
             that.data.timeUpdateFunction = function( event ) {
               Popcorn.timeUpdate( that, event );
             }
-
-            !isDestroyed && that.media.addEventListener( "timeupdate", that.data.timeUpdateFunction, false );
+            
+            if ( !that.isDestroyed ) {
+              that.media.addEventListener( "timeupdate", that.data.timeUpdateFunction, false );
+            }
           }
         } else {
           global.setTimeout(function() {
         events[ item ] = null;
       }
 
-      instance.media.removeEventListener( "timeupdate", instance.data.timeUpdateFunction, false );
-      isDestroyed = true;
+      if ( !instance.isDestroyed ) {
+        instance.media.removeEventListener( "timeupdate", instance.data.timeUpdateFunction, false );
+        instance.isDestroyed = true;
+      }
 
       Popcorn.removeInstance( instance );
     }