本文整理匯總了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
}
}
}
示例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)
}
示例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
}
示例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
}
示例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
}