Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend body width to fix a bug where events aren't triggered once the body is off page #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ <h1 id="title">Life</h1>
}
d.text = d.text.replace(link[0], "<a href='" + link[2] + "'" + link_attr + ">" + link[1] + "</a>");
}

return '<div class="event" style="margin-left: ' + offset.toFixed(2) + 'px">'
+ '<div class="time" style="width: ' + width.toFixed(2) + 'px"></div>'
+ '<b>' + d.time.title + '</b> ' + d.text + '&nbsp;&nbsp;'
Expand All @@ -284,6 +284,10 @@ <h1 id="title">Life</h1>
// Get the first and last year for the year axis
var firstYear = new Date().getFullYear();
var lastYear = firstYear;
var nowYear = new Date().getFullYear();
var yearLength = life.yearLength;
var dayLength = yearLength/12/30;

data.forEach(function(d){
var time = d.time;
var startYear = time.startYear;
Expand All @@ -298,6 +302,9 @@ <h1 id="title">Life</h1>
html += life.renderEvent(d);
});
life.$el.innerHTML = html;

// Fixes bug where mousewheel events aren't triggered once the body is off page
document.body.style.width = (nowYear - firstYear) * yearLength + 'px';
}
};

Expand Down