Code revamp
- Better sticky position for the years headers - Replace blur effect with gradients - Fix scrolling bug on Chrome
This commit is contained in:
parent
8830cdf2a5
commit
61fc68ff7d
83
index.html
83
index.html
@ -5,36 +5,29 @@
|
|||||||
<meta name="format-detection" content="telephone=no">
|
<meta name="format-detection" content="telephone=no">
|
||||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,300">
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,300">
|
||||||
<style>
|
<style>
|
||||||
html{
|
|
||||||
font-family: Open Sans, Helvetica, Arial, sans-serif;
|
|
||||||
cursor: -webkit-grab;
|
|
||||||
cursor: -moz-grab;
|
|
||||||
cursor: grab;
|
|
||||||
}
|
|
||||||
html{
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
body{
|
body{
|
||||||
min-height: 100%;
|
font-family: Open Sans, Helvetica, Arial, sans-serif;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background-color: #384047;
|
background-color: #384047;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
-webkit-text-size-adjust: none;
|
-webkit-text-size-adjust: none;
|
||||||
position: relative;
|
-webkit-user-select: none;
|
||||||
overflow: hidden;
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
cursor: default;
|
||||||
}
|
}
|
||||||
a{
|
a{
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
header{
|
header{
|
||||||
z-index: 2;
|
z-index: 3;
|
||||||
background-color: rgba(56, 64, 71, .75);
|
background: linear-gradient(to bottom, rgba(56,64,71,0) 0%,rgba(56,64,71,.5) 20%,rgba(56,64,71,1) 50%,rgba(56,64,71,.5) 80%,rgba(56,64,71,0) 100%);
|
||||||
-webkit-backdrop-filter: blur(5px);
|
position: fixed;
|
||||||
backdrop-filter: blur(5px);
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
@ -50,7 +43,6 @@ header a:hover{
|
|||||||
h1{
|
h1{
|
||||||
display: inline;
|
display: inline;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
font-weight: normal;
|
|
||||||
line-height: 1em;
|
line-height: 1em;
|
||||||
opacity: .5;
|
opacity: .5;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
@ -59,55 +51,66 @@ h1{
|
|||||||
}
|
}
|
||||||
#life{
|
#life{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
top: 0;
|
||||||
height: 100%;
|
right: 0;
|
||||||
box-sizing: border-box;
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
|
cursor: -webkit-grab;
|
||||||
|
cursor: -moz-grab;
|
||||||
|
cursor: grab;
|
||||||
}
|
}
|
||||||
#life-years{
|
#life-years{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
#life-years section.year{
|
#life-years .year{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
-moz-box-sizing: border-box;
|
|
||||||
color: #fff;
|
color: #fff;
|
||||||
pointer-events: none;
|
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
border-left: 1px dashed rgba(255,255,255,.2);
|
||||||
}
|
}
|
||||||
#life-years section.year:nth-child(even){
|
#life-years .year:first-child{
|
||||||
background: linear-gradient(to bottom, rgba(255,255,255,.05) 0%, rgba(255,255,255,0) 100%);
|
border-left: 0;
|
||||||
}
|
}
|
||||||
#life-years section.year span{
|
#life-years .year span{
|
||||||
background-color: rgba(56, 64, 71, .75);
|
background: linear-gradient(to bottom, rgba(56,64,71,1) 30%,rgba(56,64,71,0) 100%);
|
||||||
-webkit-backdrop-filter: blur(5px);
|
|
||||||
backdrop-filter: blur(5px);
|
|
||||||
display: block;
|
display: block;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
position: -webkit-sticky;
|
position: -webkit-sticky;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
z-index: 3;
|
||||||
}
|
}
|
||||||
#life-years section.year span i{
|
#life-years .year span i{
|
||||||
opacity: .5;
|
opacity: .5;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
#life-events{
|
#life-events{
|
||||||
margin-top: 40px;
|
padding-top: 40px;
|
||||||
padding-bottom: 5em;
|
padding-bottom: 5em;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
#life-events:after{
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
|
clear: left;
|
||||||
}
|
}
|
||||||
#life .event{
|
#life .event{
|
||||||
padding-right: 20px;
|
padding-right: 20px;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
float: left;
|
||||||
|
clear: left;
|
||||||
}
|
}
|
||||||
#life .event b{
|
#life .event b{
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
@ -301,7 +304,7 @@ h1{
|
|||||||
|
|
||||||
return '<div class="event" style="margin-left: ' + offset.toFixed(2) + 'px">'
|
return '<div class="event" style="margin-left: ' + offset.toFixed(2) + 'px">'
|
||||||
+ '<div class="time" style="width: ' + width.toFixed(2) + 'px"></div>'
|
+ '<div class="time" style="width: ' + width.toFixed(2) + 'px"></div>'
|
||||||
+ '<b>' + d.time.title + '</b> ' + d.text + ' '
|
+ '<b>' + d.time.title + '</b> ' + d.text
|
||||||
+ '</div>';
|
+ '</div>';
|
||||||
},
|
},
|
||||||
renderYears: function(firstYear, lastYear){
|
renderYears: function(firstYear, lastYear){
|
||||||
@ -311,9 +314,9 @@ h1{
|
|||||||
var hideAge = life.config.hideAge;
|
var hideAge = life.config.hideAge;
|
||||||
for (var y=firstYear, age = 0; y<=lastYear+1; y++, age++){
|
for (var y=firstYear, age = 0; y<=lastYear+1; y++, age++){
|
||||||
var days = (y % 4 == 0) ? 366 : 365;
|
var days = (y % 4 == 0) ? 366 : 365;
|
||||||
html += '<section class="year" style="width: ' + (days*dayLength).toFixed(2) + 'px"><span>'
|
html += '<div class="year" style="width: ' + (days*dayLength).toFixed(2) + 'px"><span>'
|
||||||
+ y + (hideAge ? '' : (' <i>(' + age + ')</i>'))
|
+ y + (hideAge ? '' : (' <i>(' + age + ')</i>'))
|
||||||
+ '</span></section>';
|
+ '</span></div>';
|
||||||
}
|
}
|
||||||
return html;
|
return html;
|
||||||
},
|
},
|
||||||
@ -333,8 +336,9 @@ h1{
|
|||||||
});
|
});
|
||||||
life.firstYear = firstYear;
|
life.firstYear = firstYear;
|
||||||
|
|
||||||
var html = '<div id="life-years">' + life.renderYears(firstYear, lastYear) + '</div>';
|
var html = '<div id="life-events">';
|
||||||
html += '<div id="life-events">';
|
// 'comment_' class name is to hide it from Safari Reader
|
||||||
|
html += '<div id="life-years" class="comment_">' + life.renderYears(firstYear, lastYear) + '</div>';
|
||||||
data.forEach(function(d){
|
data.forEach(function(d){
|
||||||
html += life.renderEvent(d);
|
html += life.renderEvent(d);
|
||||||
});
|
});
|
||||||
@ -347,7 +351,7 @@ h1{
|
|||||||
startingMousePostition: {},
|
startingMousePostition: {},
|
||||||
containerOffset: {},
|
containerOffset: {},
|
||||||
init: function(){
|
init: function(){
|
||||||
life.$el.addEventListener('mousedown', function(event){
|
window.addEventListener('mousedown', function(event){
|
||||||
slider.startingMousePostition = {
|
slider.startingMousePostition = {
|
||||||
x: event.clientX,
|
x: event.clientX,
|
||||||
y: event.clientY
|
y: event.clientY
|
||||||
@ -366,7 +370,8 @@ h1{
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var x = slider.containerOffset.x + (slider.startingMousePostition.x - event.clientX);
|
var x = slider.containerOffset.x + (slider.startingMousePostition.x - event.clientX);
|
||||||
var y = slider.containerOffset.y + (slider.startingMousePostition.y - event.clientY);
|
var y = slider.containerOffset.y + (slider.startingMousePostition.y - event.clientY);
|
||||||
life.$el.scrollTo(x, y);
|
life.$el.scrollLeft = x;
|
||||||
|
life.$el.scrollTop = y;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user