devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
88 lines (87 loc) • 3.18 kB
JavaScript
/**
* DevExtreme (esm/__internal/ui/slider/slider_tooltip_position_controller.js)
* Version: 25.2.3
* Build date: Fri Dec 12 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import positionUtils from "../../../common/core/animation/position";
import {
move
} from "../../../common/core/animation/translator";
import $ from "../../../core/renderer";
import {
extend
} from "../../../core/utils/extend";
import {
isDefined
} from "../../../core/utils/type";
import {
isCommonPosition,
PopoverPositionController
} from "../../ui/popover/popover_position_controller";
const SLIDER_CLASS = "dx-slider";
const SLIDER_TOOLTIP_POSITION_ALIASES = {
top: {
my: "bottom center",
at: "top center",
collision: "fit none"
},
bottom: {
my: "top center",
at: "bottom center",
collision: "fit none"
}
};
const DEFAULT_BOUNDARY_OFFSET = {
h: 2,
v: 1
};
export class SliderTooltipPositionController extends PopoverPositionController {
_normalizePosition(position) {
var _$sliderHandle$closes;
const {
target: target
} = this._properties;
const $sliderHandle = target ? $(target) : null;
const sliderElement = null === $sliderHandle || void 0 === $sliderHandle || null === (_$sliderHandle$closes = $sliderHandle.closest(".dx-slider")) || void 0 === _$sliderHandle$closes ? void 0 : _$sliderHandle$closes.get(0);
const defaultPositionConfig = {
of: $sliderHandle,
boundaryOffset: DEFAULT_BOUNDARY_OFFSET,
boundary: sliderElement
};
const positionObject = isDefined(position) ? this._positionToObject(position) : {};
const resultPosition = extend(true, {}, defaultPositionConfig, positionObject);
this._positionSide = this._getDisplaySide(resultPosition);
return resultPosition
}
_renderContentInitialPosition() {
super._renderContentInitialPosition();
this._fitIntoSlider()
}
_fitIntoSlider() {
var _this$_visualPosition;
const calculatedPosition = positionUtils.calculate(this._$content, this._position);
const {
collisionSide: collisionSide,
oversize: oversize
} = calculatedPosition.h;
const left = (null === (_this$_visualPosition = this._visualPosition) || void 0 === _this$_visualPosition ? void 0 : _this$_visualPosition.left) ?? 0;
const isLeftSide = "left" === collisionSide;
const offset = (isLeftSide ? 1 : -1) * oversize;
if (this._$content) {
move(this._$content, {
left: left + offset
})
}
this._updateVisualPositionValue()
}
_positionToObject(position) {
if (isCommonPosition(position)) {
const configuration = Object.assign({}, SLIDER_TOOLTIP_POSITION_ALIASES[position]);
return configuration
}
return position
}
}