当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fullcalendar.divideDurationByDuration函数代码示例

本文整理汇总了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;未经允许,请勿转载。