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

TypeScript fullcalendar.divideDurationByDuration函数代码示例

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

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



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

示例1: validateLabelAndSlot

function validateLabelAndSlot(timelineView: TimelineView) {
  const { currentUnzonedRange } = timelineView.dateProfile

  // make sure labelInterval doesn't exceed the max number of cells
  if (timelineView.labelInterval) {
    const labelCnt = core.divideRangeByDuration(currentUnzonedRange.getStart(), currentUnzonedRange.getEnd(), timelineView.labelInterval)
    if (labelCnt > (core as any).MAX_TIMELINE_SLOTS) {
      core.warn('slotLabelInterval results in too many cells')
      timelineView.labelInterval = null
    }
  }

  // make sure slotDuration doesn't exceed the maximum number of cells
  if (timelineView.slotDuration) {
    const slotCnt = core.divideRangeByDuration(currentUnzonedRange.getStart(), currentUnzonedRange.getEnd(), timelineView.slotDuration)
    if (slotCnt > (core as any).MAX_TIMELINE_SLOTS) {
      core.warn('slotDuration results in too many cells')
      timelineView.slotDuration = null
    }
  }

  // make sure labelInterval is a multiple of slotDuration
  if (timelineView.labelInterval && timelineView.slotDuration) {
    const slotsPerLabel = core.divideDurationByDuration(timelineView.labelInterval, timelineView.slotDuration)
    if (!core.isInt(slotsPerLabel) || (slotsPerLabel < 1)) {
      core.warn('slotLabelInterval must be a multiple of slotDuration')
      return timelineView.slotDuration = null
    }
  }
}
开发者ID:diomed,项目名称:fullcalendar-scheduler,代码行数:30,代码来源:TimelineView.defaults.ts


示例2: initScaleProps

export function initScaleProps(timelineView: TimelineView) {

  timelineView.labelInterval = queryDurationOption(timelineView, 'slotLabelInterval')
  timelineView.slotDuration = queryDurationOption(timelineView, 'slotDuration')

  validateLabelAndSlot(timelineView) // validate after computed grid duration
  ensureLabelInterval(timelineView)
  ensureSlotDuration(timelineView)

  let input = timelineView.opt('slotLabelFormat')
  const type = $.type(input)
  timelineView.headerFormats =
    type === 'array' ?
      input
    : type === 'string' ?
      [ input ]
    :
      computeHeaderFormats(timelineView)

  timelineView.isTimeScale = core.durationHasTime(timelineView.slotDuration)

  let largeUnit = null
  if (!timelineView.isTimeScale) {
    const slotUnit = core.computeGreatestUnit(timelineView.slotDuration)
    if (/year|month|week/.test(slotUnit)) {
      largeUnit = slotUnit
    }
  }
  timelineView.largeUnit = largeUnit

  timelineView.emphasizeWeeks = (timelineView.slotDuration.as('days') === 1) &&
    (timelineView.currentRangeAs('weeks') >= 2) &&
    !timelineView.opt('businessHours')

  /*
  console.log('label interval =', timelineView.labelInterval.humanize())
  console.log('slot duration =', timelineView.slotDuration.humanize())
  console.log('header formats =', timelineView.headerFormats)
  console.log('isTimeScale', timelineView.isTimeScale)
  console.log('largeUnit', timelineView.largeUnit)
  */

  let rawSnapDuration = timelineView.opt('snapDuration')
  timelineView.snapDuration =
    rawSnapDuration ?
      moment.duration(rawSnapDuration) :
      timelineView.slotDuration

  timelineView.snapsPerSlot = core.divideDurationByDuration(timelineView.slotDuration, timelineView.snapDuration)
}
开发者ID:diomed,项目名称:fullcalendar-scheduler,代码行数:50,代码来源:TimelineView.defaults.ts


示例3: ensureLabelInterval

function ensureLabelInterval(timelineView: TimelineView) {
  const { currentUnzonedRange } = timelineView.dateProfile
  let { labelInterval } = timelineView

  if (!labelInterval) {

    // compute based off the slot duration
    // find the largest label interval with an acceptable slots-per-label
    let input
    if (timelineView.slotDuration) {
      for (input of STOCK_SUB_DURATIONS) {
        const tryLabelInterval = moment.duration(input)
        const slotsPerLabel = core.divideDurationByDuration(tryLabelInterval, timelineView.slotDuration)
        if (core.isInt(slotsPerLabel) && (slotsPerLabel <= MAX_AUTO_SLOTS_PER_LABEL)) {
          labelInterval = tryLabelInterval
          break
        }
      }

      // use the slot duration as a last resort
      if (!labelInterval) {
        labelInterval = timelineView.slotDuration
      }

    // compute based off the view's duration
    // find the largest label interval that yields the minimum number of labels
    } else {
      for (input of STOCK_SUB_DURATIONS) {
        labelInterval = moment.duration(input)
        const labelCnt = core.divideRangeByDuration(currentUnzonedRange.getStart(), currentUnzonedRange.getEnd(), labelInterval)
        if (labelCnt >= MIN_AUTO_LABELS) {
          break
        }
      }
    }

    timelineView.labelInterval = labelInterval
  }

  return labelInterval
}
开发者ID:diomed,项目名称:fullcalendar-scheduler,代码行数:41,代码来源:TimelineView.defaults.ts


示例4: computeSlotWidth

  computeSlotWidth() { // compute the *default*
    let maxInnerWidth = 0 // TODO: harness core's `matchCellWidths` for this
    const innerEls = this.timeHeadEl.find('tr:last-child th .fc-cell-text') // TODO: cache

    innerEls.each(function(i, node) {
      const innerWidth = $(node).outerWidth()
      return maxInnerWidth = Math.max(maxInnerWidth, innerWidth)
    })

    const headerWidth = maxInnerWidth + 1 // assume no padding, and one pixel border
    const slotsPerLabel = divideDurationByDuration(this.labelInterval, this.slotDuration) // TODO: rename labelDuration?
    let slotWidth = Math.ceil(headerWidth / slotsPerLabel)

    let minWidth = this.timeHeadColEls.eq(0).css('min-width')
    if (minWidth) {
      minWidth = parseInt(minWidth, 10)
      if (minWidth) {
        slotWidth = Math.max(slotWidth, minWidth)
      }
    }

    return slotWidth
  }
开发者ID:diomed,项目名称:fullcalendar-scheduler,代码行数:23,代码来源:TimelineView.ts


示例5: ensureSlotDuration

function ensureSlotDuration(timelineView: TimelineView) {
  const { currentUnzonedRange } = timelineView.dateProfile
  let { slotDuration } = timelineView

  if (!slotDuration) {
    const labelInterval = ensureLabelInterval(timelineView) // will compute if necessary

    // compute based off the label interval
    // find the largest slot duration that is different from labelInterval, but still acceptable
    for (let input of STOCK_SUB_DURATIONS) {
      const trySlotDuration = moment.duration(input)
      const slotsPerLabel = core.divideDurationByDuration(labelInterval, trySlotDuration)
      if (core.isInt(slotsPerLabel) && (slotsPerLabel > 1) && (slotsPerLabel <= MAX_AUTO_SLOTS_PER_LABEL)) {
        slotDuration = trySlotDuration
        break
      }
    }

    // only allow the value if it won't exceed the view's # of slots limit
    if (slotDuration) {
      const slotCnt = core.divideRangeByDuration(currentUnzonedRange.getStart(), currentUnzonedRange.getEnd(), slotDuration)
      if (slotCnt > MAX_AUTO_CELLS) {
        slotDuration = null
      }
    }

    // use the label interval as a last resort
    if (!slotDuration) {
      slotDuration = labelInterval
    }

    timelineView.slotDuration = slotDuration
  }

  return slotDuration
}
开发者ID:diomed,项目名称:fullcalendar-scheduler,代码行数:36,代码来源:TimelineView.defaults.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript fullcalendar.divideRangeByDuration函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ftp.on函数代码示例发布时间: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