smooth puzzle moves scroll with requestIdleCallback
parent
4f8a1e2a1a
commit
5322c86184
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue