Watch/Monitor attribute attribute changes.
Feedback to @leifcr
Source: Github
Unit tests: Unit tests
Documentation: Github (Readme.md)
Click to grow the box below. (Note that the moving box will also notify about the change in position.)
Change 'color' and 'background-color' | Change 'color' | Change 'background-color'
How jQuery css watch was initialized in this example using CoffeeScript (yes you should use it...):
# for the growing div:
$('#watch-me-grow').on("css-change", (event, change) =>
$(".output_grow").text("I'm growing: width: #{change.width} height: #{change.height} ");
)
$('#watch-me-grow').csswatch({props: 'width,height',
props_functions: {"width":"width()", "height":"height()"}
})
# for the moving div:
$('#watch-me-move').on("css-change", (event, change) =>
$(".output_position").text("I'm growing: width: #{change.width} height: #{change.height} ");
)
$('#watch-me-move').csswatch({props: 'top,left',
props_functions: {"top":"offset().top", "left":"offset().left"}
})
# for the color changing div
$('#watch-me-change-colors').on("css-change", (event, change) =>
$(".output_colors").text("I got some new colors: #{JSON.stringify(change)}");
)
$('#watch-me-change-colors').csswatch({props: 'color,background-color'})