forked from shama/resize-event
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
27 lines (23 loc) · 688 Bytes
/
example.js
File metadata and controls
27 lines (23 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var onResize = require('./index.js')
var objectAssign = require('object-assign')
var element = document.createElement('div')
document.body.appendChild(element)
objectAssign(element.style, {
width: '400px',
height: '400px',
border: '1px solid #000',
margin: '1em auto',
padding: '1em',
'text-align': 'center',
'font-family': 'Helvetica, sans-serif'
})
onResize(element, function () {
element.textContent = 'Resized to ' + element.offsetWidth + 'px / ' + element.offsetHeight + 'px'
})
setInterval(function () {
if (Math.random() > .5) {
element.style.width = Math.random() * 500 + 'px'
} else {
element.style.height = Math.random() * 500 + 'px'
}
}, 100)