Skip to content

Commit 0efda28

Browse files
committed
Updated README to include the watch option
1 parent 3a30628 commit 0efda28

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,26 @@ You can also simply use one of the built in methods of transforming DOM elements
6161
// uses margin-left, margin-top, width and height
6262
fit( bar, foo, fit.cssMargin );
6363

64-
But fit.js was designed to be used with any kind of rectangular object, not just DOM elements.
64+
But fit.js was designed to be used with any kind of rectangular object, not just DOM elements
6565

6666
var area = { x: 20, y: 20, width: 400, height: 300 };
6767
var rect = { x: 0, y: 0, width: 100, height: 120 };
6868
fit( rect, area );
6969

70+
If you are using the DOM, you can tell fit to run again whenever the window resizes. To do this, simply set the `watch` option to `true`
71+
72+
// This will trigger a fit each time the window resizes
73+
var watching = fit( bar, foo, { watch: true } );
74+
75+
// You can stop watching at any time
76+
watching.off();
77+
78+
// And start watching again
79+
watching.on();
80+
81+
// And trigger a fit manually too
82+
watching.trigger();
83+
7084
For some visual examples, check out the [demo page](http://soulwire.github.io/fit.js/).
7185

7286
### Why?

0 commit comments

Comments
 (0)