add dragscroll extension for tournamentSchedule
parent
38fa2b658e
commit
5278d58131
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
@moreJs = {
|
@moreJs = {
|
||||||
@jsAt(s"compiled/lichess.tournament-schedule${isProd??(".min")}.js")
|
@jsAt(s"compiled/lichess.tournament-schedule${isProd??(".min")}.js")
|
||||||
|
@jsAt("javascripts/vendor/dragscroll.js")
|
||||||
@embedJs {
|
@embedJs {
|
||||||
var lichess = lichess || {};
|
var lichess = lichess || {};
|
||||||
lichess.tournamentSchedule = LichessTournamentSchedule(document.getElementById('tournament_schedule'), {
|
lichess.tournamentSchedule = LichessTournamentSchedule(document.getElementById('tournament_schedule'), {
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
/**
|
||||||
|
* @fileoverview dragscroll - scroll area by dragging
|
||||||
|
* @version 0.0.5
|
||||||
|
*
|
||||||
|
* @license MIT, see http://github.com/asvd/dragscroll
|
||||||
|
* @copyright 2015 asvd <heliosframework@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
(function (root, factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
define(['exports'], factory);
|
||||||
|
} else if (typeof exports !== 'undefined') {
|
||||||
|
factory(exports);
|
||||||
|
} else {
|
||||||
|
factory((root.dragscroll = {}));
|
||||||
|
}
|
||||||
|
}(this, function (exports) {
|
||||||
|
var _window = window;
|
||||||
|
var _document = document;
|
||||||
|
var mousemove = 'mousemove';
|
||||||
|
var mouseup = 'mouseup';
|
||||||
|
var mousedown = 'mousedown';
|
||||||
|
var EventListener = 'EventListener';
|
||||||
|
var addEventListener = 'add'+EventListener;
|
||||||
|
var removeEventListener = 'remove'+EventListener;
|
||||||
|
|
||||||
|
var dragged = [];
|
||||||
|
var reset = function(i, el) {
|
||||||
|
for (i = 0; i < dragged.length;) {
|
||||||
|
el = dragged[i++];
|
||||||
|
el[removeEventListener](mousedown, el.md, 0);
|
||||||
|
_window[removeEventListener](mouseup, el.mu, 0);
|
||||||
|
_window[removeEventListener](mousemove, el.mm, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
dragged = _document.getElementsByClassName('dragscroll');
|
||||||
|
for (i = 0; i < dragged.length;) {
|
||||||
|
(function(el, lastClientX, lastClientY, pushed){
|
||||||
|
el[addEventListener](
|
||||||
|
mousedown,
|
||||||
|
el.md = function(e) {
|
||||||
|
pushed = 1;
|
||||||
|
lastClientX = e.clientX;
|
||||||
|
lastClientY = e.clientY;
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
}, 0
|
||||||
|
);
|
||||||
|
|
||||||
|
_window[addEventListener](
|
||||||
|
mouseup, el.mu = function() {pushed = 0;}, 0
|
||||||
|
);
|
||||||
|
|
||||||
|
_window[addEventListener](
|
||||||
|
mousemove,
|
||||||
|
el.mm = function(e, scroller) {
|
||||||
|
scroller = el.scroller||el;
|
||||||
|
if (pushed) {
|
||||||
|
scroller.scrollLeft -=
|
||||||
|
(- lastClientX + (lastClientX=e.clientX));
|
||||||
|
scroller.scrollTop -=
|
||||||
|
(- lastClientY + (lastClientY=e.clientY));
|
||||||
|
}
|
||||||
|
}, 0
|
||||||
|
);
|
||||||
|
})(dragged[i++]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (_document.readyState == 'complete') {
|
||||||
|
reset();
|
||||||
|
} else {
|
||||||
|
_window[addEventListener]('load', reset, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.reset = reset;
|
||||||
|
}));
|
||||||
|
|
|
@ -159,7 +159,7 @@ module.exports = function(ctrl) {
|
||||||
var tourLanes = splitOverlaping(
|
var tourLanes = splitOverlaping(
|
||||||
group(ctrl.data.systemTours, speedGrouper).concat([ctrl.data.userTours]));
|
group(ctrl.data.systemTours, speedGrouper).concat([ctrl.data.userTours]));
|
||||||
|
|
||||||
return m('div.schedule', {
|
return m('div.schedule.dragscroll', {
|
||||||
config: function(el, isUpdate) {
|
config: function(el, isUpdate) {
|
||||||
if (!isUpdate) scrollToNow(el);
|
if (!isUpdate) scrollToNow(el);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue