Por lo que yo sé, la única manera de hacer esto sería con un temporizador.
he creado un pequeño plugin jQuery (sí, aquí, en este momento) que hace esto en contra de un conjunto de jQuery:
EDITAR este plugin está ahora en GitHub: https://github.com/jacobrelkin/jquery-watcher
$.fn.watch = function(property, callback) {
return $(this).each(function() {
var self = this;
var old_property_val = this[property];
var timer;
function watch() {
if($(self).data(property + '-watch-abort') == true) {
timer = clearInterval(timer);
$(self).data(property + '-watch-abort', null);
return;
}
if(self[property] != old_property_val) {
old_property_val = self[property];
callback.call(self);
}
}
timer = setInterval(watch, 700);
});
};
$.fn.unwatch = function(property) {
return $(this).each(function() {
$(this).data(property + '-watch-abort', true);
});
};
Uso :
$('.watch-me').watch('style', function() {
//"this" in this scope will reference the object on which the property changed
if($(this).css('display') == 'block') {
//do something...
}
});
Para borrar este observador propiedad:
$('.watch-me').unwatch('style');
He probado esto localmente, y funciona. :) –
Para todos los interesados: https://github.com/jrelkin/jquery-watcher –
y luego ¿cuál será el código aquí? '//" this "en este ámbito hará referencia al objeto sobre el que cambió la propiedad' – GusDeCooL