devextreme
Version:
JavaScript/TypeScript Component Suite for Responsive Web Development
71 lines (70 loc) • 2.83 kB
JavaScript
/**
* DevExtreme (esm/__internal/scheduler/shaders/current_time_shader_horizontal.js)
* Version: 25.2.7
* Build date: Tue May 05 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() {
const groupCount = this.workSpace._isHorizontalGroupedWorkSpace() ? this.workSpace._getGroupCount() : 1;
for (let i = 0; i < groupCount; i += 1) {
const isFirstShader = 0 === i;
const $shader = isFirstShader ? this.$shader : this.createShader();
if (this.workSpace.isGroupedByDate()) {
this.customizeGroupedByDateShader($shader, i)
} else {
this.customizeShader($shader, i)
}
if (!isFirstShader) {
this.shader.push($shader)
}
}
}
customizeShader($shader, groupIndex) {
const shaderWidth = this.workSpace.getIndicationWidth();
this.applyShaderWidth($shader, shaderWidth);
if (groupIndex >= 1) {
const {
workSpace: workSpace
} = this;
const indicationWidth = workSpace._getCellCount() * 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) {
const cellCount = this.workSpace.getIndicationCellCount();
const integerPart = Math.floor(cellCount);
const fractionPart = cellCount - 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 = workSpace._getCellCount() * workSpace.getCellWidth() * groupIndex
} else {
shaderLeft = workSpace.getCellWidth() * integerPart * workSpace._getGroupCount() + groupIndex * workSpace.getCellWidth()
}
$shader.css("left", shaderLeft)
}
}
export default HorizontalCurrentTimeShader;