Skip to content

Commit

Permalink
Remove dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
fr3fou committed Aug 4, 2018
1 parent 08508b3 commit eed6499
Show file tree
Hide file tree
Showing 8 changed files with 985 additions and 244 deletions.
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
*
!/src
!.gitignore
!gulpfile.js
!package.json
.cache/*
dist/*
node_modules/*
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"git.ignoreLimitWarning": true
}
6 changes: 0 additions & 6 deletions package.json

This file was deleted.

2 changes: 1 addition & 1 deletion src/js/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Preview.prototype.load = function (beatmapID, success, fail) {
}
}
});
this.xhr.open('GET', "/dist/osu.txt");
this.xhr.open('GET', "/temp/osu.txt");
this.xhr.send();
};
Preview.prototype.at = function (time) {
Expand Down
43 changes: 13 additions & 30 deletions src/js/viewbox.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,52 @@
/** viewbox stretches child to fit parent proportionally.
*
* viewbox must have a child that has two attributes, 'width' and 'height'.
*/
document.addEventListener('DOMContentLoaded', function()
{
document.addEventListener('DOMContentLoaded', () => {
window.addEventListener('resize', thunk);
thunk();

function thunk()
{
var viewboxes = document.getElementsByClassName('x-viewbox');
for (var i = 0; i < viewboxes.length; i++)
{
function thunk() {
let viewboxes = document.getElementsByClassName('x-viewbox');
for (let i = 0; i < viewboxes.length; i++) {
onresize.call(viewboxes[i]);
}
}

function onresize()
{
var parent = this.parentElement,
function onresize() {
let parent = this.parentElement,
child = this.firstChild,
w, h, cw, ch, sw, sh, s;

if (!parent)
{
if (!parent) {
w = window.innerWidth;
h = window.innerHeight;
}
else
{
else {
w = parent.scrollWidth;
h = parent.scrollHeight;
}

if (child)
{
if (child) {
child.style.transformOrigin = '0 0';

cw = child.width;
ch = child.height;
}
sw = w / cw;
sh = h / ch;
// if viewbox has no child that has proper attributes,
// ignore size of child and re-calculate scale.
if ((sw || sh) == NaN)
{
if ((sw || sh) == NaN) {
sw = w;
sh = h;
}

if (sw > sh)
{
if (sw > sh) {
this.style.width = sh * cw + 'px';
this.style.height = h + 'px';
s = sh;
}
else
{
else {
this.style.width = w + 'px';
this.style.height = sw * ch + 'px';
s = sw;
}
if (child)
{
if (child) {
child.style.transform = 'scale(' + s + ')';
}
}
Expand Down
Loading

0 comments on commit eed6499

Please sign in to comment.