本文整理汇总了TypeScript中bobril.now函数的典型用法代码示例。如果您正苦于以下问题:TypeScript now函数的具体用法?TypeScript now怎么用?TypeScript now使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了now函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: init
export const Toggle = b.createComponent<IToggleData>({
init(ctx: IToggleCtx) {
ctx.focusFromKeyboard = false;
ctx.down = false;
ctx.rippleStart = 0;
},
render(ctx: IToggleCtx, me: b.IBobrilNode) {
let d = ctx.data;
let disabled = d.disabled;
let checked = d.checked;
let focusFromKeyboard = ctx.focusFromKeyboard;
let hasRipple = ctx.rippleStart != 0;
let t: number = 0;
let r: number = 0;
if (hasRipple) {
t = (b.now() - ctx.rippleStart) * 0.004;
if (t > 2) {
hasRipple = false;
ctx.rippleStart = 0;
}
r = Math.min(t * toggleSize, toggleSize);
b.invalidate(ctx);
}
if (focusFromKeyboard) {
hasRipple = true;
r = toggleSize;
t = 1;
}
b.style(me, rootStyle, disabled ? disabledStyle : enabledStyle);
me.children = [
b.styledDiv(null, trackStyle, checked && trackToggledStyle, disabled && trackDisabledStyle),
示例2: header
b.init(() => [
header({ fontSize: 20 }, t('Hello')),
warnHeader({ fontSize: 25, isWarning: true }, 'World'),
header({ fontSize: 15 }, t('Right now is {now, date, LLLL}', { now: b.now() }))
]);
示例3: render
ctx.focusFromKeyboard = false;
ctx.down = false;
ctx.rippleStart = 0;
ctx.rippleReq = false;
},
render(ctx: ICheckboxCtx, me: b.IBobrilNode) {
let d = ctx.data;
let ics = d.icons || checkBoxIcons;
ctx.radio = !!ics.radioButtonLike;
let disabled = d.disabled;
let checked = d.checked;
let indeterminate = d.indeterminate;
if (indeterminate === true) checked = false;
let focusFromKeyboard = ctx.focusFromKeyboard;
let rippleReq = focusFromKeyboard || ctx.down;
let time = b.now();
let rr = 0;
let ro = 0;
if (rippleReq && !ctx.rippleReq) {
ctx.rippleStart = time;
}
ctx.rippleReq = rippleReq;
let showFocus = false;
if (ctx.rippleStart !== 0) {
let t = (time - ctx.rippleStart) * 0.005;
if (t > (focusFromKeyboard ? 1.5 : 2)) {
if (focusFromKeyboard) showFocus = true;
if (!rippleReq) ctx.rippleStart = 0;
} else {
if (t < 1) {
ro = 0.4;