I'm designing an object as follows. But JavaScript does not nested callable. I thank colleagues an idea about it. I share the original code.
var preloading = {};
Object.defineProperties(preloading,{
show:{
enumarable:true,
writable:false,
value:function(value){
var $this = this;
jQuery($this._object).find('.text').eq(0).html($this.text).end().end()
.velocity('stop').velocity('fadeIn',{
duration:500,
complete:function(){
console.log('preloading show');
if(value instanceof Function || typeof value === 'function'){
$this._start(value);
}
}
});
}
},
hide:{
enumarable:true,
writable:false,
value:function(value){
var $this = this;
jQuery($this._object).velocity('stop').velocity('fadeOut',{
duration:500,
complete:function(){
console.log('preloading hide');
if(value instanceof Function || typeof value === 'function'){
$this._finish(value);
}
}
});
}
},
_start:{
enumerable:false,
writable:false,
value:function(value){
var $this = this;
value.call(undefined, $this);
}
},
_finish:{
enumerable:false,
writable:false,
value:function(value){
var $this = this;
value.call(undefined, $this)
}
},
_object:{
writable:true,
value:'#preloader2',
enumarable:false
},
object:{
get:function(){
return this._object;
},
set:function(value){
this._object = value;
}
},
_text:{
writable:true,
value:'yükleniyor..',
enumerable:false
},
text:{
get:function(){
return this._text;
},
set:function(value){
this._text = value;
}
}
});
then i try
preloading.show(function(preloading){preloading.hide()})
--first callback starting
//show callback starting
--second callback not starting
an idea?