diff --git a/examples/Animated/Flock.html b/examples/Animated/Flock.html index a42bea83..5bc4ee0d 100644 --- a/examples/Animated/Flock.html +++ b/examples/Animated/Flock.html @@ -14,9 +14,6 @@ strokeWidth: 2, strokeCap: 'round' }; - var bounds = document.bounds, - width = bounds.width, - height = bounds.height; var head = new Path.Oval([0, 0], [13, 8]); head.fillColor = 'white'; @@ -131,7 +128,9 @@ borders: function() { var loc = this.loc, r = this.r, - oldLoc = this.loc.clone(); + oldLoc = this.loc.clone(), + width = document.size.width, + height = document.size.height; if (loc.x < -r) loc.x = width + r; if (loc.y < -r) loc.y = height + r; if (loc.x > width + r) loc.x = -r; @@ -273,8 +272,19 @@ function onMouseDown(event) { groupTogether = !groupTogether; } + + // Resize the document, whenever the window is resized, + window.onresize = function(event) { + document.size = [window.innerWidth, window.innerHeight]; + heartPath.position = document.bounds.center; + document.redraw(); + } + + // Call straight away to resize the document to the current + // window size: + window.onresize(); - - + + \ No newline at end of file