update TimePicker & BackTop
update TimePicker & BackTop
This commit is contained in:
parent
36628acaab
commit
2d94873892
9 changed files with 179 additions and 98 deletions
|
@ -86,7 +86,7 @@ function firstUpperCase(str) {
|
|||
export function warnProp(component, prop, correctType, wrongType) {
|
||||
correctType = firstUpperCase(correctType);
|
||||
wrongType = firstUpperCase(wrongType);
|
||||
console.error(`[iView warn]: Invalid prop: type check failed for prop ${prop}. Expected ${correctType}, got ${wrongType}. (found in component: ${component})`);
|
||||
console.error(`[iView warn]: Invalid prop: type check failed for prop ${prop}. Expected ${correctType}, got ${wrongType}. (found in component: ${component})`); // eslint-disable-line
|
||||
}
|
||||
|
||||
function typeOf(obj) {
|
||||
|
@ -131,4 +131,37 @@ function deepCopy(data) {
|
|||
return o;
|
||||
}
|
||||
|
||||
export {deepCopy};
|
||||
export {deepCopy};
|
||||
|
||||
// scrollTop animation
|
||||
export function scrollTop(el, from = 0, to, duration = 500) {
|
||||
if (!window.requestAnimationFrame) {
|
||||
window.requestAnimationFrame = (
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function (callback) {
|
||||
return window.setTimeout(callback, 1000/60);
|
||||
}
|
||||
)
|
||||
}
|
||||
const difference = Math.abs(from - to);
|
||||
const step = Math.ceil(difference / duration * 50);
|
||||
|
||||
function scroll(start, end, step) {
|
||||
if (start === end) return;
|
||||
|
||||
let d = (start + step > end) ? end : start + step;
|
||||
if (start > end) {
|
||||
d = (start - step < end) ? end : start - step;
|
||||
}
|
||||
|
||||
if (el === window) {
|
||||
window.scrollTo(d, d);
|
||||
} else {
|
||||
el.scrollTop = d;
|
||||
}
|
||||
window.requestAnimationFrame(() => scroll(d, end, step));
|
||||
}
|
||||
scroll(from, to, step);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue