2022.2

Table Of Contents
Thisfunctioncouldforinstancebeusedinadesignwherecontentneedstoflowseparatelyfromthe
maintextflow,orwhereanew,full-page,multi-columnboxshouldbeinsertedwhenthecurrentone
overflows.
NotethatwhencalledinaStandardscript,thismethodrunsbeforethepaginationofPrintoutput.After
pagination-intheoutput,andinPreviewmode-theelement'soverflowmayhavechanged,especially
whentheelementiscombinedwithfloatingelements(i.e.elementsthathavetheCSSstylefloat)and
locatednearapage-break.
Topreventthisfromhappening,itmayhelptosettheelement'sCSSstyletooverflow:hidden.
Theoverflows()methodcanalsobeusedinaPostPaginationscript.
Tip: Youdon'tneedascripttoresizetextinordertomakeitfitinabox.TheCopyFitfeatureauto-
maticallyscalestexttotheavailablespace(see"CopyFit"onpage685).
Examples
var $box = query("#mybox");
while ( ! $box.overflows()) {
//do something
}
Aslightlyshorterversion:
while ( ! query("#mybox").overflows()) {
//do something
}
Thefollowingscriptselectsthreeboxesthatallhavetheclassbox(selector:.box).Itloopsoverthem,
insertingasmanyproductsfromanarrayaspossibleintothebox.Infact,itinsertsonetoomanyand
removesthelastonebeforemovingontothenextbox.
var products = ["Appetizer","Beans","Beef","Lettuce","Sprouts","Coconut","Juice","Soup","Coriander","Cheese","Pasta","Sugar","Vinegar","Bread"];
var i = 0;
results.each( function() {
// Add elements to the box until it overflows.
while ( ! this.overflows() && i < products.length ) {
this.append("<p>" + products[i] + "</p>");
i++;
}
// Go one step back unless we processed all items in our array.
if( i < products.length ) {
query("p:last-child", this).remove();
i--;
}
});
section
Thesectionobjectcanbeusedtoqueryandmodifyhowthesection(andtherelatedcontext)willbe
outputted.ItisoneofthemostimportantobjectsinControlScripts(see"ControlScripts"onpage838
Page 1305