开源软件名称:sdecima/javascript-detect-element-resize开源软件地址:https://github.com/sdecima/javascript-detect-element-resize开源编程语言:JavaScript 99.0%开源软件介绍:javascript-detect-element-resizeA Cross-Browser, Event-based, Element Resize Detection. In short, this implementation does NOT use an internal timer to detect size changes (as most implementations I found do).
It uses The method used not only detects javascript generated resize changes but also changes made from CSS pseudo classes e.g. :hover, CSS animations, etc. About the librariesI was searching for a library that allowed me to detect when an DOM element changes size, and all solutions I found had two problems:
Then I came across this great post on Back Alley Coder about using The libraries on this repository are just a ready-to-use implementation of the above, one pure javascript and the other a jQuery plugin version (just for convenience). LibrariesPure Javascript library usage<script type="text/javascript" src="detect-element-resize.js"></script>
<script type="text/javascript">
var resizeElement = document.getElementById('resizeElement'),
resizeCallback = function() {
/* do something */
};
addResizeListener(resizeElement, resizeCallback);
removeResizeListener(resizeElement, resizeCallback);
</script> jQuery plugin library usage<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.resize.js"></script>
<script type="text/javascript">
var myFunc = function() {
/* do something */
};
$('#resizeElement').resize(myFunc);
$('#resizeElement').removeResize(myFunc);
</script> CompatibilityWorks great on:
Known Issues:
Doesn't work on:
Please let me know if you test these libraries on any other browser, of if you run into issues with any of the above browsers. TODO
Release Notesv0.5.3
v0.5.2
v0.5.1
v0.5
v0.4.1
v0.4
v0.3
v0.2
v0.1
ReferencesSimilar libraries (but they use timers)Don't get me wrong, these are great libraries and work as advertised, it's just that they are not easy on browser resources. External linksBack Alley Coder: Cross-Browser, Event-based, Element Resize Detection |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论