Skip to content

Commit

Permalink
Merge pull request #53 from marklonquist/master
Browse files Browse the repository at this point in the history
Case #99310: fixed an issue with map not trying to load on pageload. …
  • Loading branch information
Dan9boi authored Sep 9, 2016
2 parents abdc14c + 076756f commit ef1b58c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 15 deletions.
18 changes: 14 additions & 4 deletions gulp/tasks/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,26 @@ const mergeStream = require('merge-stream');
const fs = require('fs');
const rsp = require('remove-svg-properties').stream;
var plugins = require('gulp-load-plugins')();
var mkdirp = require('mkdirp');

function writeFile(path, fileName, content) {
try {
if (!fs.existsSync(path)) {
fs.mkdirSync(path)
mkdirp(path, function (err) {
if (err) { console.error(err) }
else {
doWrite(path, fileName, content);
}
});
} else {
doWrite(path, fileName, content);
}

fs.writeFileSync(path + fileName, content);
console.log("icons.json is being generated.");
return path + fileName;
function doWrite(path, fileName, content) {
fs.writeFileSync(path + fileName, content);
console.log("icons.json is being generated.");
return path + fileName;
}
} catch (e) {
console.log(e);
return null;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"jshint-stylish": "^2.2.0",
"jshint-stylish-cool": "^2.0.2",
"merge-stream": "~1.0.0",
"mkdirp": "^0.5.1",
"node-notifier": "^4.6.0",
"remove-svg-properties": "^0.3.2",
"tslint": "^3.13.0",
Expand Down
30 changes: 19 additions & 11 deletions scripts/components/novicell.map.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@ novicell.map = novicell.map || function () {
var isLoaded = false;

function init() {
document.onscroll = function () {
var element = document.getElementById('map-canvas');
if (!isLoaded && element && isScrolledIntoView(element)) {
isLoaded = true;
// Async load the GMaps API and run "initialize"
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&callback=initialize';
document.body.appendChild(script);
}
};
var element = document.getElementById('map-canvas');
if (!isLoaded && element && isScrolledIntoView(element)) {
load();
} else {
document.onscroll = function () {
if (!isLoaded && element && isScrolledIntoView(element)) {
load();
}
};
}
}

function load() {
isLoaded = true;
// Async load the GMaps API and run "initialize"
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&callback=initialize';
document.body.appendChild(script);
}

return {
Expand Down

0 comments on commit ef1b58c

Please sign in to comment.