devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
71 lines (70 loc) • 2.89 kB
JavaScript
/**
* DevExtreme (esm/__internal/scheduler/shaders/current_time_shader_horizontal.js)
* Version: 26.1.3
* Build date: Wed Jun 10 2026
*
* Copyright (c) 2012 - 2026 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import {
getBoundingRect
} from "../../../core/utils/position";
import {
setWidth
} from "../../../core/utils/size";
import CurrentTimeShader from "./current_time_shader";
class HorizontalCurrentTimeShader extends CurrentTimeShader {
renderShader(isHorizontalGroupedWorkSpace, groupCount, cellCount) {
const effectiveGroupCount = isHorizontalGroupedWorkSpace ? groupCount : 1;
for (let i = 0; i < effectiveGroupCount; i += 1) {
const isFirstShader = 0 === i;
const $shader = isFirstShader ? this.$shader : this.createShader();
if (this.workSpace.isGroupedByDate()) {
this.customizeGroupedByDateShader($shader, i, groupCount, cellCount)
} else {
this.customizeShader($shader, i, cellCount)
}
if (!isFirstShader) {
this.shader.push($shader)
}
}
}
customizeShader($shader, groupIndex, dateTableCellCount) {
const shaderWidth = this.workSpace.getIndicationWidth();
this.applyShaderWidth($shader, shaderWidth);
if (groupIndex >= 1) {
const {
workSpace: workSpace
} = this;
const indicationWidth = dateTableCellCount * workSpace.getCellWidth();
$shader.css("left", indicationWidth)
} else {
$shader.css("left", 0)
}
}
applyShaderWidth($shader, width) {
const maxWidth = getBoundingRect(this.$container.get(0)).width;
if (width > 0) {
setWidth($shader, Math.min(width, maxWidth))
}
}
customizeGroupedByDateShader($shader, groupIndex, shaderGroupCount, dateTableCellCount) {
const indicationCellCount = this.workSpace.getIndicationCellCount();
const integerPart = Math.floor(indicationCellCount);
const fractionPart = indicationCellCount - integerPart;
const isFirstShaderPart = 0 === groupIndex;
const {
workSpace: workSpace
} = this;
const shaderWidth = isFirstShaderPart ? workSpace.getIndicationWidth() : fractionPart * workSpace.getCellWidth();
let shaderLeft = 0;
this.applyShaderWidth($shader, shaderWidth);
if (isFirstShaderPart) {
shaderLeft = dateTableCellCount * workSpace.getCellWidth() * groupIndex
} else {
shaderLeft = workSpace.getCellWidth() * integerPart * shaderGroupCount + groupIndex * workSpace.getCellWidth()
}
$shader.css("left", shaderLeft)
}
}
export default HorizontalCurrentTimeShader;