Skip to content

Commit

Permalink
Cleaned up internal refresh function [#806]
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher De Cairos committed Nov 1, 2011
2 parents 984ce76 + 3273441 commit 439283a
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions popcorn.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"addTrackEvent removeTrackEvent getTrackEvents getTrackEvent getLastTrackEventId " +
"timeUpdate plugin removePlugin compose effect parser xhr getJSONP getScript" ).split(/\s+/);

while( methods.length ) {
while ( methods.length ) {
global.Popcorn[ methods.shift() ] = function() {};
}
return;
Expand Down Expand Up @@ -58,39 +58,39 @@
};
}()),

refresh = function ( obj ) {
refresh = function( obj ) {
var currentTime = obj.media.currentTime,
animation = obj.options.frameAnimation,
disabled = obj.data.disabled,
tracks = obj.data.trackEvents,
animating = tracks.animating,
start = tracks.startIndex,
animIndex = 0,
disabled = obj.data.disabled,
registryByName = Popcorn.registryByName,
animIndex = 0,
byStart, natives, type;

start = Math.min( start + 1, tracks.byStart.length - 2 );

while ( start > 0 && tracks.byStart[ start ] ) {

byStart = tracks.byStart [ start ];
byStart = tracks.byStart[ start ];
natives = byStart._natives;
type = natives && natives.type;

if ( !natives ||
( !!registryByName[ type ] || !!obj[ type ] ) ) {

if ( byStart.start <= currentTime &&
byStart.end > currentTime &&
disabled.indexOf( type ) === -1 ) {
if ( ( byStart.start <= currentTime && byStart.end > currentTime ) &&
disabled.indexOf( type ) === -1 ) {

if ( !byStart._running ) {
byStart._running = true;
natives.start.call( obj, null, byStart );

// if the 'frameAnimation' option is used,
// push the current byStart object into the `animating` cue
if ( obj.options.frameAnimation &&
( byStart && byStart._running && byStart.natives.frame ) ) {
if ( animation &&
( byStart && byStart._running && byStart.natives.frame ) ) {

natives.frame.call( obj, null, byStart, currentTime );
}
Expand All @@ -100,13 +100,12 @@
byStart._running = false;
natives.end.call( obj, null, byStart );

if ( obj.options.frameAnimation && byStart._natives.frame ) {
if ( animation && byStart._natives.frame ) {
animIndex = animating.indexOf( byStart );
if ( animIndex >= 0 ) {
animating.splice( animIndex, 1 );
}
}

}
}

Expand Down

0 comments on commit 439283a

Please sign in to comment.