• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript snabbdom.h函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中snabbdom.h函数的典型用法代码示例。如果您正苦于以下问题:TypeScript h函数的具体用法?TypeScript h怎么用?TypeScript h使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了h函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: renderChildrenOf

function renderChildrenOf(ctx, node, opts): MaybeVNodes {
  const cs = node.children, main = cs[0];
  if (!main) return [];
  if (opts.isMainline) {
    const isWhite = main.ply % 2 === 1;
    if (!cs[1]) return [
      isWhite ? renderIndex(main.ply, false) : null,
      ...renderMoveAndChildrenOf(ctx, main, {
        parentPath: opts.parentPath,
        isMainline: true
      })
    ];
    const mainChildren = renderChildrenOf(ctx, main, {
      parentPath: opts.parentPath + main.id,
      isMainline: true
    }),
    passOpts = {
      parentPath: opts.parentPath,
      isMainline: true
    };
    return [
      isWhite ? renderIndex(main.ply, false) : null,
      renderMoveOf(ctx, main, passOpts),
      isWhite ? emptyMove() : null,
      h('interrupt', renderLines(ctx, cs.slice(1), {
        parentPath: opts.parentPath,
        isMainline: true
      })),
      ...(isWhite && mainChildren ? [
        renderIndex(main.ply, false),
        emptyMove()
      ] : []),
      ...mainChildren
    ];
  }
  return cs[1] ? [renderLines(ctx, cs, opts)] : renderMoveAndChildrenOf(ctx, main, opts);
}
开发者ID:luanlv,项目名称:lila,代码行数:37,代码来源:tree.ts


示例2: function

export default function(ctrl: Controller): VNode {
  const showCeval = ctrl.vm.showComputer();
  if (cevalShown !== showCeval) {
    if (!cevalShown) ctrl.vm.autoScrollNow = true;
    cevalShown = showCeval;
  }
  return h('div#puzzle.cg-512', [
    h('div', {
      hook: {
        insert: _ => window.lichess.pubsub.emit('reset_zoom')()
      },
      class: { gauge_displayed: ctrl.showEvalGauge() }
    }, [
      h('div.lichess_game' + (ctrl.pref.blindfold ? '.blindfold' : ''), {
        hook: {
          insert: _ => window.lichess.pubsub.emit('content_loaded')()
        }
      }, [
        visualBoard(ctrl),
        h('div.lichess_ground', [
          // we need the wrapping div here
          // so the siblings are only updated when ceval is added
          h('div', showCeval ? [
            cevalView.renderCeval(ctrl),
            cevalView.renderPvs(ctrl)
          ] : []),
          renderAnalyse(ctrl),
          feedbackView(ctrl),
          buttons(ctrl)
        ])
      ])
    ]),
    h('div.underboard', [
      h('div.center', [
        historyView(ctrl)
      ])
    ])
  ]);
};
开发者ID:ddugovic,项目名称:lila,代码行数:39,代码来源:main.ts


示例3: renderTournament

function renderTournament(ctrl, tour) {
  let width = tour.minutes * scale;
  const left = leftPos(tour.startsAt);
  // moves content into viewport, for long tourneys and marathons
  const paddingLeft = tour.minutes < 90 ? 0 : Math.max(0,
    Math.min(width - 250, // max padding, reserved text space
      leftPos(now) - left - 380)); // distance from Now
      // cut right overflow to fit viewport and not widen it, for marathons
      width = Math.min(width, leftPos(stopTime) - left);

      return h('a.tournament', {
        class: tournamentClass(tour),
        attrs: {
          href: '/tournament/' + tour.id,
          style: 'width: ' + width + 'px; left: ' + left + 'px; padding-left: ' + paddingLeft + 'px'
        },
      }, [
        h('span.icon', tour.perf ? {
          attrs: {
            'data-icon': tour.perf.icon,
            title: tour.perf.name
          }
        } : {}),
        h('span.body', [
          h('span.name', tour.fullName),
          h('span.infos', [
            h('span.text', [
              displayClock(tour.clock) + ' ',
              tour.variant.key === 'standard' ? null : tour.variant.name + ' ',
              tour.position ? 'Thematic ' : null,
              tour.rated ? ctrl.trans('rated') : ctrl.trans('casual')
            ]),
            tour.nbPlayers ? h('span.nb-players', {
              attrs: { 'data-icon': 'r' }
            }, tour.nbPlayers) : null
          ])
        ])
      ]);
}
开发者ID:lexisvar,项目名称:lila,代码行数:39,代码来源:view.ts


示例4: view

export function view(ctrl): VNode {
  const candidates = ctrl.candidates();
  return dialog.form({
    class: 'study_invite',
    onClose() {
      ctrl.open(false);
      ctrl.redraw();
    },
    content: [
      h('h2', 'Invite to the study'),
      h('p.info', { attrs: { 'data-icon': '' } }, [
        'Please only invite people you know,',
        h('br'),
        'and who actively want to join this study.'
      ]),
      candidates.length ? h('div.users', candidates.map(function(username) {
        return h('span.user_link.button', {
          key: username,
          attrs: { 'data-href': '/@/' + username },
          hook: bind('click', _ => ctrl.invite(username))
        }, username);
      })) : undefined,
      h('div.input-wrapper', [ // because typeahead messes up with snabbdom
        h('input', {
          attrs: { placeholder: 'Search by username' },
          hook: {
            insert: vnode => {
              const el = vnode.elm as HTMLInputElement;
              window.lichess.userAutocomplete($(el), {
                tag: 'span',
                onSelect(v) {
                  ctrl.invite(v.name);
                  $(el).typeahead('close');
                  el.value = '';
                  ctrl.redraw();
                }
              });
            }
          }
        })
      ])
    ]
  });
}
开发者ID:ddugovic,项目名称:lila,代码行数:44,代码来源:inviteForm.ts


示例5: h

 ctrl.data.nowPlaying.map(function(pov) {
   return h('a.mini_board.is2d.' + pov.variant.key + (pov.isMyTurn ? '.my_turn' : ''), {
     key: pov.gameId,
     attrs: { href: '/' + pov.fullId }
   }, [
     h('div', [
       h('div.cg-board-wrap', {
         hook: {
           insert(vnode) {
             const lm = pov.lastMove;
             const config = {
               coordinates: false,
               drawable: { enabled: false, visible: false },
               resizable: false,
               viewOnly: true,
               orientation: pov.variant.key === 'racingKings' ? 'white' : pov.color,
               fen: pov.fen,
               lastMove: lm && [lm[0] + lm[1], lm[2] + lm[3]]
             };
             Chessground(vnode.elm as HTMLElement, config);
           }
         }
       }, [ h('div.cg-board') ])
     ]),
     h('span.meta', [
       pov.opponent.ai ? ctrl.trans('aiNameLevelAiLevel', 'Stockfish', pov.opponent.ai) : pov.opponent.username,
       h('span.indicator',
         pov.isMyTurn ?
         (pov.secondsLeft ? timer(pov) : ctrl.trans('yourTurn')) :
         h('span', {
           hook: {
             insert(vnode) {
               (vnode.elm as HTMLElement).innerHTML = '&nbsp;';
             }
           }
         }))
     ])
   ]);
 }));
开发者ID:lexisvar,项目名称:lila,代码行数:39,代码来源:playing.ts


示例6: function

export default function(ctrl, color, position) {
  if (!ctrl.node.crazy) return;
  const pocket = ctrl.node.crazy.pockets[color === 'white' ? 0 : 1];
  const dropped = ctrl.justDropped;
  let captured = ctrl.justCaptured;
  if (captured) {
    captured = captured.promoted ? 'pawn' : captured.role;
  }
  const activeColor = color === ctrl.turnColor();
  const usable = !ctrl.embed && activeColor;
  return h('div.pocket.is2d.' + position, {
    class: { usable },
    hook: {
      insert: vnode => {
        if (ctrl.embed) return;
        eventNames.forEach(name => {
          (vnode.elm as HTMLElement).addEventListener(name, e => drag(ctrl, color, e as MouchEvent));
        });
      }
    }
  }, oKeys.map(role => {
    let nb = pocket[role] || 0;
    if (activeColor) {
      if (dropped === role) nb--;
      if (captured === role) nb++;
    }
    return h('piece.' + role + '.' + color, {
      attrs: {
        'data-role': role,
        'data-color': color,
        'data-nb': nb
      }
    });
  })
  );
}
开发者ID:lexisvar,项目名称:lila,代码行数:36,代码来源:crazyView.ts


示例7: renderMoves

function renderMoves(ctrl: RoundController): MaybeVNodes {
  const steps = ctrl.data.steps,
    firstPly = round.firstPly(ctrl.data),
    lastPly = round.lastPly(ctrl.data);
  if (typeof lastPly === 'undefined') return [];

  const pairs: Array<Array<any>> = [];
  let startAt = 1;
  if (firstPly % 2 === 1) {
    pairs.push([null, steps[1]]);
    startAt = 2;
  }
  for (let i = startAt; i < steps.length; i += 2) pairs.push([steps[i], steps[i + 1]]);

  const els: MaybeVNodes = [], curPly = ctrl.ply;
  for (let i = 0; i < pairs.length; i++) {
    els.push(h('index', i + 1 + ''));
    els.push(renderMove(pairs[i][0], curPly));
    els.push(renderMove(pairs[i][1], curPly));
  }
  els.push(renderResult(ctrl));

  return els;
}
开发者ID:ornicar,项目名称:lila,代码行数:24,代码来源:replay.ts


示例8: return

 return (c: Challenge) => {
   return h('div.challenge.' + dir + '.c-' + c.id, {
     class: {
       declined: !!c.declined
     }
   }, [
     h('div.content', [
       h('span.head', renderUser(dir === 'in' ? c.challenger : c.destUser)),
       h('span.desc', [
         ctrl.trans()(c.rated ? 'rated' : 'casual'),
         timeControl(c.timeControl),
         c.variant.name
       ].join(' • '))
     ]),
     h('i', {
       attrs: {'data-icon': c.perf.icon}
     }),
     h('div.buttons', (dir === 'in' ? inButtons : outButtons)(ctrl, c))
   ]);
 };
开发者ID:ddugovic,项目名称:lila,代码行数:20,代码来源:view.ts


示例9: view

export function view(ctrl: BoardCtrl): VNode {

  return h('div.sub.board', [
    header(ctrl.trans.noarg('boardGeometry'), ctrl.close),
    h('div.selector', [
      h('a.text', {
        class: { active: !ctrl.data.is3d },
        attrs: { 'data-icon': 'E' },
        hook: bind('click', () => ctrl.setIs3d(false))
      }, '2D'),
      h('a.text', {
        class: { active: ctrl.data.is3d },
        attrs: { 'data-icon': 'E' },
        hook: bind('click', () => ctrl.setIs3d(true))
      }, '3D')
    ]),
    h('div.zoom', [
      h('h2', ctrl.trans.noarg('boardSize')),
      h('div.slider', {
        hook: { insert: vnode => makeSlider(ctrl, vnode.elm as HTMLElement) }
      })
    ])
  ]);
}
开发者ID:ddugovic,项目名称:lila,代码行数:24,代码来源:board.ts


示例10: renderIndexAndMove

export function renderIndexAndMove(ctx: Ctx, node): VNode[] {
  return node.uci ?
  [renderIndex(node.ply, ctx.withDots)].concat(renderMove(ctx, node)) :
  [h('span.init', 'Initial position')];
}
开发者ID:lexisvar,项目名称:lila,代码行数:5,代码来源:moveView.ts



注:本文中的snabbdom.h函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript snabbdom.init函数代码示例发布时间:2022-05-25
下一篇:
TypeScript smtp-server.SMTPServer类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap