devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
94 lines (92 loc) • 3 kB
JavaScript
/**
* DevExtreme (cjs/ui/drawer/ui.drawer.animation.js)
* Version: 23.2.6
* Build date: Wed May 01 2024
*
* Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
"use strict";
exports.animation = void 0;
var _fx = _interopRequireDefault(require("../../animation/fx"));
var _inflector = require("../../core/utils/inflector");
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
}
}
const animation = {
moveTo(config) {
const $element = config.$element;
const position = config.position;
const direction = config.direction || "left";
const toConfig = {};
let animationType;
switch (direction) {
case "right":
toConfig.transform = "translate(" + position + "px, 0px)";
animationType = "custom";
break;
case "left":
toConfig.left = position;
animationType = "slide";
break;
case "top":
case "bottom":
toConfig.top = position;
animationType = "slide"
}
_fx.default.animate($element, {
type: animationType,
to: toConfig,
duration: config.duration,
complete: config.complete
})
},
margin(config) {
const $element = config.$element;
const margin = config.margin;
const direction = config.direction || "left";
const toConfig = {};
toConfig["margin" + (0, _inflector.camelize)(direction, true)] = margin;
_fx.default.animate($element, {
to: toConfig,
duration: config.duration,
complete: config.complete
})
},
fade($element, config, duration, completeAction) {
_fx.default.animate($element, {
type: "fade",
to: config.to,
from: config.from,
duration: duration,
complete: completeAction
})
},
size(config) {
const $element = config.$element;
const size = config.size;
const direction = config.direction || "left";
const marginTop = config.marginTop || 0;
const duration = config.duration;
const toConfig = {};
if ("right" === direction || "left" === direction) {
toConfig.width = size
} else {
toConfig.height = size
}
if ("bottom" === direction) {
toConfig.marginTop = marginTop
}
_fx.default.animate($element, {
to: toConfig,
duration: duration,
complete: config.complete
})
},
complete($element) {
_fx.default.stop($element, true)
}
};
exports.animation = animation;