JSFiddle - React, Tailwind, and code Playground
https://jsfiddle.net/levchenko_d/djy4h7u0/3/#update
by levchenko_d
HTML
<script src="https://beat.today/app/js/app.min.js"></script>
<link rel="stylesheet" href="https://beat.today/app/css/style.min.css">
<div id="log"></div>
<div class="calendar-wrapper"></div>
CSS
.calendar-wrapper {
position: relative;
height: 300px;
overflow: hidden;
box-shadow: 0 1px 5px 1px rgba(0,0,0,0.3);
margin: 10px;
border-radius: 5px;
margin: 20px auto;
width: 400px;
}
.calendar-today{
background: red;
}
.calendar-topbar{
height: 50px;
width: 100%;
position: relactive;
background: #fff;
z-index: 9;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.calendar-view {
position: relative;
height: 250px;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
.calendar-year:first-of-type{
}
.calendar-month{
position: relative;
opacity: 0.5;
}
.year-title{
display: none;
}
#log{
display: none;
position: fixed;
width: 100px;
max-height: 200px;
overflow-y: scroll;
background: #fff;
z-index: 99999;
box-shadow: 0 2px 3px silver;
}
.month-title{
position: absolute;
height: 36px;
top: 0;
left: 0;
right: 0;
bottom: 0;
text-align: center;
margin: auto;
opacity: 0.1;
font-size: 36px;
z-index: 0;
}
.calendar-week{
position: relative;
}
.calendar-week:after{
display: table;
content: '';
clear: both;
}
.calendar-day{
float: left;
width: 14.285714285714286%;
padding: 5px 10px;
height: 50px;
font-family: 'Muli','Lato','Open Sans','Helvetica Neue',Helvetica,sans-serif;
font-size: 11px;
}
.calendar-day:hover{
background: rgba(0,0,0,0.07);
}
.calendar-topbar-date {
line-height: 50px;
padding: 0 20px;
font-family: 'Muli','Lato','Open Sans','Helvetica Neue',Helvetica,sans-serif;
font-size: 14px;
color: #565656;
}
.calendar-week[data-calendar-skip-days='1'] .calendar-day:first-of-type{
margin-left: 14.285714285714286%;
}
.calendar-week[data-calendar-skip-days='2'] .calendar-day:first-of-type{
margin-left: 28.571428571428573%;
}
.calendar-week[data-calendar-skip-days='3'] .calendar-day:first-of-type{
margin-left: 42.85714285714286%;
}
.calendar-week[data-calendar-skip-days='4'] .calendar-day:first-of-type{
margin-left:...
JavaScript
function parseIntSafe(n){
return (parseInt(n, 10)||0);
}
App.Follow.prototype.getBounds = function(){
var t=this;
function getElementBounds(element, index){
var topBound = element.offsetTop,
bottomBound = topBound + element.size().y;
element.followData = {
bounds : {
top: topBound,
bottom: bottomBound
}
};
element.addClass(t.o.followingClass);
}
t.elementDOMs.loop(getElementBounds);
};
App.Follow.prototype.attachEvents = function(){
var t=this;
t.onScroll = function(){
t.scrollTop = App.getScrollTop(App.q('.calendar-view'));
t.findMatchingBounds(function(element){
if(!element){
App.isFn(t.o.onNoMatch)(t.previousElement);
if(t.previousElement){
t.previousElement.removeClass(t.o.matchClass);
App.isFn(t.o.onLeave)(t.previousElement);
}
t.previousElement = null;
} else {
element.addClass(t.o.matchClass);
if(element != t.previousElement){
if(t.previousElement){
t.previousElement.removeClass(t.o.matchClass);
App.isFn(t.o.onLeave)(t.previousElement);
}
App.isFn(t.o.onEnter)(element);
t.previousElement = element;
}
}
});
};
App.q('.calendar-view').addEventListener('scroll', t.onScroll);
};
App.run = function(fn, times, callback){
for(var i=0; i<times+1; i++){
if(i===times){
App.isFn(callback)();
} else {
App.isFn(fn)(i);
}
}
};
var Calendar = function(options){
var t = this;
t.o = options;
t.element = App.q(t.o.element);
t.instances = {};
t.curretDate = new Date();
t.shownDate = new Date(); //the one is shown
t.allowMonthDetection = true; //inertia scroll bug
t.currentDayDate = 1; //outer iterator for createDay();
t.isInitialMonth = true;// see Folllow
t.rowHeight = t.o.rowHeight || 50;
...