element-resize-event-polyfill
Version:
Native event listener polyfill to capture element size changes
36 lines (35 loc) • 1.06 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<style>
.container {
width: 300px;
height: 200px;
border: 1px solid;
resize: both;
overflow: auto;
}
</style>
<title>Document</title>
</head>
<body>
<div class="container" id="container"></div>
</body>
<!-- <script src="../dist/element-resize-event-polyfill.umd.js"></script> -->
<script type="module">
import '../dist/element-resize-event-polyfill.umd.js'
const elm = document.getElementById('container')
elm.addEventListener('resize', function(e) {
console.log('Trigger resizable event by listener one')
})
elm.addEventListener('resize', function(e) {
console.log('Trigger resizable event by listener two')
})
elm.onresize = function(e) {
console.log('Trigger resizable event by handler')
}
</script>
</html>