Skip to content

Commit

Permalink
Use Sun loader again
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Lawrence committed Jul 12, 2018
1 parent 8e0adc1 commit 676f1a1
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 66 deletions.
4 changes: 2 additions & 2 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import Apod from './scripts/components/Apod';
import Drawer from './scripts/components/Drawer';
import topSites from './scripts/utils/buildTopSites';
import { SunLoader, MoonLoader, CubeLoader, FloatingHistoryLoader } from './scripts/LoadingSpinner';
import { SunLoader, MoonLoader, CubeLoader } from './scripts/LoadingSpinner';
import ExplanationTab from './scripts/tabs/ExplanationTab';
import FavoritesTab from './scripts/tabs/FavoritesTab';
import { $, randomizer } from './scripts/utilities';

import './styles/style.scss';

export const loader = new FloatingHistoryLoader();
export const loader = new SunLoader();
$('#apod-loading').appendChild(loader.render());

export const drawer = new Drawer('#apod-drawer');
Expand Down
2 changes: 1 addition & 1 deletion client/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "APOD by The Trav",
"short_name": "APOD by The Trav",
"description": "Displays the Astronomy Picture of the Day (APOD) as your new tab page",
"version": "2.3.4",
"version": "2.3.3",

"browser_action": {
"default_icon": "images/sun_icon.png",
Expand Down
40 changes: 1 addition & 39 deletions client/scripts/LoadingSpinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,42 +87,4 @@ class CubeLoader {
}
}

class FloatingHistoryLoader {
constructor() {
this.el = htmlToElements(`
<div class="floating-history"></div>
`);

chrome.storage.sync.get(['apodFavorites'], favorites => {
if (favorites.apodFavorites) {
for(let favorite in favorites.apodFavorites) {
this.updateBackground(favorites.apodFavorites[favorite].imgUrl);
}
}
});
}

loadFloatingImage(url) {
const background = htmlToElements(`<div class="floating-image"></div>`)
background.style['background-image'] = `url(${url})`;
background.style['top'] = `${randomizer(100)}%`;
background.style['left'] = `${randomizer(100)}%`;
background.style['transform'] = `translateZ(-${randomizer(1000)}px)`;

this.el.appendChild(background);
}

updateBackground(url) {
const bgImg = new Image();
bgImg.src = url;
bgImg.onload = () => {
this.loadFloatingImage(url);
}
}

render() {
return this.el;
}
}

export { SunLoader, MoonLoader, CubeLoader, FloatingHistoryLoader };
export { SunLoader, MoonLoader, CubeLoader };
2 changes: 1 addition & 1 deletion client/scripts/components/History.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class History {
this.pastDates.push(response);
this.currentIdx = this.pastDates.length - 1;

if (this.pastDates[this.currentIdx - 1]) {
if (this.pastDates[this.currentIdx - 1] && loader.hasOwnProperty('updateBackground')) {
loader.updateBackground(this.pastDates[this.currentIdx - 1].url);
}
}
Expand Down
22 changes: 0 additions & 22 deletions client/styles/_apod_loading_floating.scss

This file was deleted.

1 change: 0 additions & 1 deletion client/styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
@include sun-loader;
@include moon-loader;
@import 'apod_loading_cube';
@import 'apod_loading_floating';
}

.spin-loader {
Expand Down

0 comments on commit 676f1a1

Please sign in to comment.