我的代码位于http://jsfiddle.net/mannagod/QT3v5/7/ http://jsfiddle.net/mannagod/QT3v5/7/.
JS 是:
function delay() {
var INTENDED_MONTH = 7 //August
// INTENDED_MONTH is zero-relative
now = new Date().getDate(),
rows = document.getElementById('scripture').rows;
if (new Date().getMonth() != INTENDED_MONTH) {
// need a value here less than 1,
// or the box for the first of the month will be in Red
now = 0.5
};
for (var i = 0, rl = rows.length; i < rl; i++) {
var cells = rows[i].childNodes;
for (j = 0, cl = cells.length; j < cl; j++) {
if (cells[j].nodeName == 'TD'
&& cells[j].firstChild.nodeValue != ''
&& cells[j].firstChild.nodeValue == now) {
// 'ffff99' // '#ffd700' // TODAY - red
rows[i].style.backgroundColor = 'red'
rows[i].scrollIntoView();
}
}
}
}
我需要找到一种方法来平滑.scrollintoview()
。现在它“跳”到突出显示的行。我需要它顺利过渡到该行。它需要动态完成以代替scrollintoview。有任何想法吗?谢谢。
在大多数现代浏览器中(Chrome 和 Firefox,但不包括 Safari、UC 或 IE https://caniuse.com/#feat=scrollintoview)您可以将对象中的选项传递给.scrollIntoView()
.
尝试这个:
elm.scrollIntoView({ behavior: 'smooth', block: 'center' })
其他值是behavior: 'instant'
or block: 'start'
or block: 'end'
. See https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView https://developer.mozilla.org/en/docs/Web/API/Element/scrollIntoView
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)