sync
This commit is contained in:
37
lib/ui.js
37
lib/ui.js
@@ -14,6 +14,38 @@ import { validation, convertCssStyle } from './ui/extension';
|
||||
import { createDateInput, toDateValue, getFormatter, formatDate, setDateValue, getDateValue, DateSelector } from './ui/date';
|
||||
import * as utility from './utility';
|
||||
|
||||
function requestAnimationFrame(callback) {
|
||||
if (typeof utility.global.requestAnimationFrame === 'function') {
|
||||
utility.global.requestAnimationFrame(callback);
|
||||
} else {
|
||||
setTimeout(callback, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function scrollLeft() {
|
||||
const n = document.documentElement;
|
||||
return (utility.global.scrollX || n.scrollLeft) - (n.clientLeft || 0);
|
||||
}
|
||||
|
||||
function scrollTop() {
|
||||
const n = document.documentElement;
|
||||
return (utility.global.scrollY || n.scrollTop) - (n.clientTop || 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {HTMLElement} e
|
||||
*/
|
||||
function offset(e) {
|
||||
const rect = e.getBoundingClientRect();
|
||||
return {
|
||||
top: rect.top + scrollTop(),
|
||||
left: rect.left + scrollLeft(),
|
||||
height: rect.height,
|
||||
width: rect.width
|
||||
};
|
||||
}
|
||||
|
||||
export {
|
||||
createElement,
|
||||
// icon
|
||||
@@ -63,5 +95,8 @@ export {
|
||||
validation,
|
||||
convertCssStyle,
|
||||
// utility
|
||||
utility
|
||||
utility,
|
||||
// functions
|
||||
requestAnimationFrame,
|
||||
offset
|
||||
}
|
||||
|
Reference in New Issue
Block a user