smooth puzzle moves scroll with requestIdleCallback

pull/2713/head^2
Thibault Duplessis 2017-02-28 04:56:09 +01:00
parent 4f8a1e2a1a
commit 5322c86184
2 changed files with 4 additions and 7 deletions

View File

@ -14,6 +14,7 @@ lichess.getParameterByName = function(name) {
var lichess_translations = lichess_translations || [];
lichess.raf = (window.requestAnimationFrame || window.setTimeout).bind(window);
lichess.requestIdleCallback = (window.requestIdleCallback || window.setTimeout).bind(window);
lichess.storage = (function() {
var withStorage = function(f) {
// can throw an exception when storage is full

View File

@ -1,14 +1,12 @@
var m = require('mithril');
var raf = require('chessground/util').raf;
var throttle = require('common').throttle;
var defined = require('common').defined;
var normalizeEval = require('chess').renderEval;
var treePath = require('tree').path;
var autoScrollNow = function(ctrl, el) {
var cont = el.parentNode;
raf(function() {
var autoScroll = function(ctrl, el) {
lichess.requestIdleCallback(function() {
var cont = el.parentNode;
var target = el.querySelector('.active');
if (!target) {
cont.scrollTop = ctrl.vm.path === treePath.root ? 0 : 99999;
@ -18,8 +16,6 @@ var autoScrollNow = function(ctrl, el) {
});
};
var autoScroll = throttle(300, false, autoScrollNow);
function pathContains(ctx, path) {
return treePath.contains(ctx.ctrl.vm.path, path);
}