15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

162<br />

<strong>JavaScript</strong> <strong>Examples</strong> <strong>Bible</strong>: The Essential Companion to <strong>JavaScript</strong> <strong>Bible</strong><br />

windowObject.moveBy()<br />

Listing 16-24 (continued)<br />

}<br />

// moves window in a circular motion<br />

function revolve() {<br />

var winX = (screen.availWidth - window.outerWidth) / 2<br />

var winY = 50<br />

window.resizeTo(400,300)<br />

window.moveTo(winX, winY)<br />

for (var i = 1; i < 36; i++) {<br />

winX += Math.cos(i * (Math.PI/18)) * 5<br />

winY += Math.sin(i * (Math.PI/18)) * 5<br />

window.moveTo(winX, winY)<br />

}<br />

}<br />

// moves window in a horizontal zig-zag pattern<br />

function zigzag() {<br />

window.resizeTo(400,300)<br />

window.moveTo(0,80)<br />

var incrementX = 2<br />

var incrementY = 2<br />

var floor = screen.availHeight - window.outerHeight<br />

var rightEdge = screen.availWidth - window.outerWidth<br />

for (var i = 0; i < rightEdge; i += 2) {<br />

window.moveBy(incrementX, incrementY)<br />

if (i%60 == 0) {<br />

incrementY = -incrementY<br />

}<br />

}<br />

}<br />

// resizes window to occupy all available screen real estate<br />

function maximize() {<br />

window.moveTo(0,0)<br />

window.resizeTo(screen.availWidth, screen.availHeight)<br />

}<br />

<br />

<br />

<br />

<br />

Window Gymnastics<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!