devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
144 lines (143 loc) • 5.17 kB
JavaScript
/**
* DevExtreme (esm/ui/popup/popup_position_controller.js)
* Version: 22.1.9
* Build date: Tue Apr 18 2023
*
* Copyright (c) 2012 - 2023 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
var _excluded = ["fullScreen", "forceApplyBindings", "dragOutsideBoundary", "dragAndResizeArea", "outsideDragFactor"];
import $ from "../../core/renderer";
import {
move
} from "../../animation/translator";
import {
getWindow
} from "../../core/utils/window";
import {
originalViewPort
} from "../../core/utils/view_port";
import {
OverlayPositionController
} from "../overlay/overlay_position_controller";
var window = getWindow();
class PopupPositionController extends OverlayPositionController {
constructor(_ref) {
var {
fullScreen: fullScreen,
forceApplyBindings: forceApplyBindings,
dragOutsideBoundary: dragOutsideBoundary,
dragAndResizeArea: dragAndResizeArea,
outsideDragFactor: outsideDragFactor
} = _ref, args = _objectWithoutPropertiesLoose(_ref, _excluded);
super(args);
this._props = _extends({}, this._props, {
fullScreen: fullScreen,
forceApplyBindings: forceApplyBindings,
dragOutsideBoundary: dragOutsideBoundary,
dragAndResizeArea: dragAndResizeArea,
outsideDragFactor: outsideDragFactor
});
this._$dragResizeContainer = void 0;
this._outsideDragFactor = void 0;
this._lastPositionBeforeFullScreen = void 0;
this._updateDragResizeContainer();
this._updateOutsideDragFactor()
}
set fullScreen(fullScreen) {
this._props.fullScreen = fullScreen;
if (fullScreen) {
this._fullScreenEnabled()
} else {
this._fullScreenDisabled()
}
}
get $dragResizeContainer() {
return this._$dragResizeContainer
}
get outsideDragFactor() {
return this._outsideDragFactor
}
set dragAndResizeArea(dragAndResizeArea) {
this._props.dragAndResizeArea = dragAndResizeArea;
this._updateDragResizeContainer()
}
set dragOutsideBoundary(dragOutsideBoundary) {
this._props.dragOutsideBoundary = dragOutsideBoundary;
this._updateDragResizeContainer();
this._updateOutsideDragFactor()
}
set outsideDragFactor(outsideDragFactor) {
this._props.outsideDragFactor = outsideDragFactor;
this._updateOutsideDragFactor()
}
updateContainer(containerProp) {
super.updateContainer(containerProp);
this._updateDragResizeContainer()
}
dragHandled() {
this.restorePositionOnNextRender(false)
}
resizeHandled() {
this.restorePositionOnNextRender(false)
}
positionContent() {
if (this._props.fullScreen) {
move(this._$content, {
top: 0,
left: 0
});
this.detectVisualPositionChange()
} else {
var _this$_props$forceApp, _this$_props;
null === (_this$_props$forceApp = (_this$_props = this._props).forceApplyBindings) || void 0 === _this$_props$forceApp ? void 0 : _this$_props$forceApp.call(_this$_props);
if (!this._shouldRenderContentInitialPosition && this._lastPositionBeforeFullScreen) {
move(this._$content, this._lastPositionBeforeFullScreen);
this._lastPositionBeforeFullScreen = void 0;
this.detectVisualPositionChange()
} else {
super.positionContent()
}
}
}
_updateOutsideDragFactor() {
this._outsideDragFactor = this._getOutsideDragFactor()
}
_getOutsideDragFactor() {
if (this._props.dragOutsideBoundary) {
return 1
}
return this._props.outsideDragFactor
}
_updateDragResizeContainer() {
this._$dragResizeContainer = this._getDragResizeContainer()
}
_getDragResizeContainer() {
if (this._props.dragOutsideBoundary) {
return $(window)
}
if (this._props.dragAndResizeArea) {
return $(this._props.dragAndResizeArea)
}
var isContainerDefined = originalViewPort().get(0) || this._props.container;
return isContainerDefined ? this._$markupContainer : $(window)
}
_getVisualContainer() {
if (this._props.fullScreen) {
return $(window)
}
return super._getVisualContainer()
}
_fullScreenEnabled() {
this.restorePositionOnNextRender(false);
this._lastPositionBeforeFullScreen = this._visualPosition
}
_fullScreenDisabled() {
this.restorePositionOnNextRender(false)
}
}
export {
PopupPositionController
};