watch dom
bower install watch-dom-vomvo
<script src="watchDOM.js" type="text/javascript"></script>
<!-- watch will be global variable -->
require("watchDOM", function(watchDOM){
...
})
var div = document.createElement('div');
var option = {
check : function(watchObj, dom){ return false; }, // more check..
/* example
check : function(watchObj, dom){
return dom.text === 'test' // => true? --> execute callback.
}
*/
delay : 50
}
var watchDiv = watchDOM(div, option);
watchDiv.start(); // start watching.
watchDiv.register(function(){
console.log('change div !');
})
//other code ...
div.innerHTML = 'Change!'; // console: 'change div !'
div.value = 'change~!'; // console: 'change div !'
// <input type='text' /> -> value change?? -> execute callback !
watchDiv.runcallbacks(); // console: 'change div !'
// return callbacks and remove the registered callbacks.
var callbacks = watchDiv.disconnect()
callbacks[0]() // console: 'change div !
div.innerHTML = 'Change!'; // callback is not registered.
div.value = 'change~!'; // callback is not registered.
// return callbacks and remove the registered callbacks.
watchDiv.stop() // watched stop.
div.innerHTML = 'Change!'; // Not watched.
div.value = 'change~!'; // Not watched.
// return callbacks and remove the registered callbacks.
watchDiv.stop() // watched stop.
watchDiv.start(); // start watching again.
div.innerHTML = 'Change!'; // console: 'change div !'
div.value = 'change~!'; // console: 'change div !'
- 2014-08-30
v0.0.1 update build module(grunt-to-commonjs) and update testfile.
v0.0.2 bug fixed, ignore dist
v0.0.3 build update, add npmignore, npmrc
- 2014-08-29
v0.0.0 release