From 1764ee07f736e572d678d8ab66b24ddc8e20a0b6 Mon Sep 17 00:00:00 2001 From: Brandon Tilley Date: Wed, 1 Jan 2014 11:49:02 -0800 Subject: [PATCH] (site) Fix incorrect plugins in quake example --- site/public/examples/quake.ejs | 11 ++++++++--- site/public/examples/quake/quake.js | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/site/public/examples/quake.ejs b/site/public/examples/quake.ejs index 2da2b11..e412f46 100644 --- a/site/public/examples/quake.ejs +++ b/site/public/examples/quake.ejs @@ -191,16 +191,20 @@ // Plugin to resize the canvas to fill the window and to // automatically center the planet when the window size changes function autocenter(options) { + options = options || {}; var needsCentering = false; + var globe = null; + var resize = function() { var width = window.innerWidth + (options.extraWidth || 0); var height = window.innerHeight + (options.extraHeight || 0); - planet.canvas.width = width; - planet.canvas.height = height; - planet.projection.translate([width / 2, height / 2]); + globe.canvas.width = width; + globe.canvas.height = height; + globe.projection.translate([width / 2, height / 2]); }; return function(planet) { + globe = planet; planet.onInit(function() { needsCentering = true; d3.select(window).on('resize', function() { @@ -217,6 +221,7 @@ // Plugin to automatically scale the planet's projection based // on the window size when the planet is initialized function autoscale(options) { + options = options || {}; return function(planet) { planet.onInit(function() { var width = window.innerWidth + (options.extraWidth || 0); diff --git a/site/public/examples/quake/quake.js b/site/public/examples/quake/quake.js index 4a0a8e8..f05da56 100644 --- a/site/public/examples/quake/quake.js +++ b/site/public/examples/quake/quake.js @@ -161,16 +161,20 @@ // Plugin to resize the canvas to fill the window and to // automatically center the planet when the window size changes function autocenter(options) { + options = options || {}; var needsCentering = false; + var globe = null; + var resize = function() { var width = window.innerWidth + (options.extraWidth || 0); var height = window.innerHeight + (options.extraHeight || 0); - planet.canvas.width = width; - planet.canvas.height = height; - planet.projection.translate([width / 2, height / 2]); + globe.canvas.width = width; + globe.canvas.height = height; + globe.projection.translate([width / 2, height / 2]); }; return function(planet) { + globe = planet; planet.onInit(function() { needsCentering = true; d3.select(window).on('resize', function() { @@ -187,6 +191,7 @@ // Plugin to automatically scale the planet's projection based // on the window size when the planet is initialized function autoscale(options) { + options = options || {}; return function(planet) { planet.onInit(function() { var width = window.innerWidth + (options.extraWidth || 0);