Fixed the problem where 'this' in ghettoWatcher() was 'window' instead of current object.
This commit is contained in:
parent
ad1436289b
commit
42cf4d91e7
@ -44,16 +44,30 @@ class PlayerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startChangeDetection(){
|
startChangeDetection(){
|
||||||
this.ghettoWatcher
|
this.scheduleGhettoWatcher();
|
||||||
this.watchTimeout = setInterval(this.ghettoWatcher, 100, this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
scheduleGhettoWatcher(){
|
scheduleGhettoWatcher(timeout, force_reset) {
|
||||||
ths = this;
|
if(! timeout){
|
||||||
|
timeout = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
// don't allow more than 1 instance
|
||||||
|
if(this.watchTimeout){
|
||||||
|
clearTimeout(this.watchTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
var ths = this;
|
||||||
|
|
||||||
this.watchTimeout = setTimeout(function(){
|
this.watchTimeout = setTimeout(function(){
|
||||||
ths.ghettoWatcher();
|
ths.watchTimeout = null;
|
||||||
ths.scheduleGhettoWatcher();
|
try{
|
||||||
}, 100)
|
ths.ghettoWatcher();
|
||||||
|
}catch(e){console.log("[PlayerData::scheduleGhettoWatcher] Scheduling failed. Error:",e)}
|
||||||
|
ths = null;
|
||||||
|
},
|
||||||
|
timeout
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
stopChangeDetection(){
|
stopChangeDetection(){
|
||||||
@ -68,10 +82,13 @@ class PlayerData {
|
|||||||
|
|
||||||
this.getPlayerDimensions();
|
this.getPlayerDimensions();
|
||||||
if(! this.element ){
|
if(! this.element ){
|
||||||
|
this.scheduleGhettoWatcher();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.videoData.resizer.restore(); // note: this returns true if change goes through, false otherwise.
|
this.videoData.resizer.restore(); // note: this returns true if change goes through, false otherwise.
|
||||||
|
|
||||||
|
this.scheduleGhettoWatcher();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,11 +105,14 @@ class PlayerData {
|
|||||||
this.getPlayerDimensions();
|
this.getPlayerDimensions();
|
||||||
|
|
||||||
if(! this.element ){
|
if(! this.element ){
|
||||||
|
this.scheduleGhettoWatcher();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.videoData.resizer.restore();
|
this.videoData.resizer.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.scheduleGhettoWatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlayerDimensions(elementNames){
|
getPlayerDimensions(elementNames){
|
||||||
|
Loading…
Reference in New Issue
Block a user