本文整理汇总了TypeScript中ux/dom.getScroll函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getScroll函数的具体用法?TypeScript getScroll怎么用?TypeScript getScroll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getScroll函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: getScroll
const step = () => {
const current = getScroll(elem);
if (current.x === last.x && current.y === last.y) {
if (Math.abs(leftX) > Math.abs(deltaX)) {
current.x += deltaX;
leftX -= deltaX;
} else {
current.x = value.x!;
}
if (Math.abs(leftY) > Math.abs(deltaY)) {
current.y += deltaY;
leftY -= deltaY;
} else {
current.y = value.y!;
}
setScroll(elem, current);
last = getScroll(elem);
setTimeout(step, 10);
} else {
callback && callback(last);
}
};
开发者ID:Teal,项目名称:TealUI,代码行数:24,代码来源:scroll.ts
示例2: scrollIntoViewIfNeeded
export function scrollIntoViewIfNeeded(elem: HTMLElement | Document, scrollable: HTMLElement | Document = scrollParent(elem), duration?: number, padding = 0, offset = 0, callback?: (value: Point) => void) {
const container = getRect(scrollable);
const rect = getRect(elem);
const deltaY = rect.y - container.y;
const deltaX = rect.x - container.x;
const value = getScroll(scrollable);
if (deltaY < padding) {
value.y += deltaY - offset;
} else if (deltaY + rect.height + padding > container.height) {
value.y += deltaY - container.height + rect.height + offset;
} else {
delete value.y;
}
if (deltaX < padding) {
value.x += deltaX - offset;
} else if (deltaX + rect.width + padding > container.width) {
value.x += deltaX - container.width + rect.width + offset;
} else {
delete value.x;
}
scrollTo(scrollable, value, duration, callback);
}
开发者ID:Teal,项目名称:TealUI,代码行数:22,代码来源:scroll.ts
示例3: scrollTo
export function scrollTo(elem: HTMLElement | Document, value: Partial<Point>, duration = 150, callback?: (value: Point) => void) {
let last = getScroll(elem);
if (duration === 0) {
setScroll(elem, value);
} else if (value.x != null || value.y != null) {
let leftX = (value.x! - last.x) || 0;
let leftY = (value.y! - last.y) || 0;
const count = duration / 10;
const deltaX = leftX / count;
const deltaY = leftY / count;
const step = () => {
const current = getScroll(elem);
if (current.x === last.x && current.y === last.y) {
if (Math.abs(leftX) > Math.abs(deltaX)) {
current.x += deltaX;
leftX -= deltaX;
} else {
current.x = value.x!;
}
if (Math.abs(leftY) > Math.abs(deltaY)) {
current.y += deltaY;
leftY -= deltaY;
} else {
current.y = value.y!;
}
setScroll(elem, current);
last = getScroll(elem);
setTimeout(step, 10);
} else {
callback && callback(last);
}
};
step();
return;
}
callback && callback(last);
}
开发者ID:Teal,项目名称:TealUI,代码行数:39,代码来源:scroll.ts
示例4: scrollIntoView
export function scrollIntoView(elem: HTMLElement | Document, position?: ScrollLogicalPosition, scrollable: HTMLElement | Document = scrollParent(elem), duration?: number, offset = 0, callback?: (value: Point) => void) {
const container = getRect(scrollable);
const rect = getRect(elem);
const deltaY = rect.y - container.y;
const deltaX = rect.x - container.x;
const value = getScroll(scrollable);
if (!position || position === "start" || position === "nearest" && deltaY <= (container.height - rect.height) / 2) {
value.y += deltaY - offset;
} else {
value.y += deltaY - container.height + rect.height + offset;
if (position === "center") {
value.y += (container.height - rect.height) / 2;
}
}
if (!position || position === "start" || position === "nearest" && deltaX <= (container.width - rect.width) / 2) {
value.x -= -deltaX + offset;
} else {
value.x -= -deltaX + container.width - rect.width - offset;
if (position === "center") {
value.x += (container.width - rect.width) / 2;
}
}
scrollTo(scrollable, value, duration, callback);
}
开发者ID:Teal,项目名称:TealUI,代码行数:24,代码来源:scroll.ts
示例5: scrollBy
export function scrollBy(elem: HTMLElement | Document, value: Partial<Point>, duration?: number, callback?: (value: Point) => void) {
const scroll = getScroll(elem);
if (value.x != null) scroll.x += value.x;
if (value.y != null) scroll.y += value.y;
scrollTo(elem, scroll, duration, callback);
}
开发者ID:Teal,项目名称:TealUI,代码行数:6,代码来源:scroll.ts
注:本文中的ux/dom.getScroll函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论