Browse files

Move "resize" event into "DOMContentLoaded" to prevent extra calls.

  • Loading branch information...
1 parent d2745dc commit e6c6b5e596f6bcb9d80559a9869d2bd682963c89 @aemkei aemkei committed Feb 9, 2012
Showing with 7 additions and 6 deletions.
  1. +7 −6 demo/resize.html
View
13 demo/resize.html
@@ -32,14 +32,15 @@
<script type="text/javascript">
viewporter.preventPageScroll = true;
-
- window.addEventListener("resize", function(){
- viewporter.refresh();
- document.getElementById("events").innerHTML += "resize<br>";
- });
-
+
document.addEventListener('DOMContentLoaded', function() {
+ // listen for "resize" events and trigger "refresh" method.
+ window.addEventListener("resize", function(){
+ viewporter.refresh();
+ document.getElementById("events").innerHTML += "resize<br>";
+ });
+
if (navigator.geolocation){
function success(position){
var coords = [position.coords.latitude, position.coords.longitude]

0 comments on commit e6c6b5e

Please sign in to comment.