做
var old = /*value*/ function loop(){ if (/*value*/ != old){ //check if the value is not old //do stuff } old = /*value*/ //set old to value requestanimationframe(loop) //loop every frame } requestanimationframe(loop) //wait a frame
或
var old = /*value*/ function changed(){ var change = /*value*/ != old //check if the value is not old old = /*value*/ //set old to value return change //output change }
并将 /*value*/ 替换为要检查的值:)