0.0.3 • Published 10 years ago
watch-dom-vomvo v0.0.3
watchDOM 0.0.3
watch dom
Install
bower
bower install watch-dom-vomvo
Use
HTML Script TAG
<script src="watchDOM.js" type="text/javascript"></script>
<!-- watch will be global variable -->
RequireJS
require("watchDOM", function(watchDOM){
...
})
API
init
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);
start and register
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 !
runCallbacks
watchDiv.runcallbacks(); // console: 'change div !'
disconnect
// 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.
stop
// return callbacks and remove the registered callbacks.
watchDiv.stop() // watched stop.
div.innerHTML = 'Change!'; // Not watched.
div.value = 'change~!'; // Not watched.
restart
// 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 !'
Release History
- 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
Thank you. :laughing:
0.0.3
10 years ago