ui.drawer.rendering.strategy.shrink.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /**
  2. * DevExtreme (ui/drawer/ui.drawer.rendering.strategy.shrink.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. function _typeof(obj) {
  11. "@babel/helpers - typeof";
  12. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
  13. return typeof obj
  14. } : function(obj) {
  15. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj
  16. }, _typeof(obj)
  17. }
  18. var _uiDrawerRendering = require("./ui.drawer.rendering.strategy");
  19. var _uiDrawerRendering2 = _interopRequireDefault(_uiDrawerRendering);
  20. var _renderer = require("../../core/renderer");
  21. var _renderer2 = _interopRequireDefault(_renderer);
  22. var _extend = require("../../core/utils/extend");
  23. var _inflector = require("../../core/utils/inflector");
  24. function _interopRequireDefault(obj) {
  25. return obj && obj.__esModule ? obj : {
  26. "default": obj
  27. }
  28. }
  29. function _classCallCheck(instance, Constructor) {
  30. if (!(instance instanceof Constructor)) {
  31. throw new TypeError("Cannot call a class as a function")
  32. }
  33. }
  34. function _defineProperties(target, props) {
  35. for (var i = 0; i < props.length; i++) {
  36. var descriptor = props[i];
  37. descriptor.enumerable = descriptor.enumerable || false;
  38. descriptor.configurable = true;
  39. if ("value" in descriptor) {
  40. descriptor.writable = true
  41. }
  42. Object.defineProperty(target, descriptor.key, descriptor)
  43. }
  44. }
  45. function _createClass(Constructor, protoProps, staticProps) {
  46. if (protoProps) {
  47. _defineProperties(Constructor.prototype, protoProps)
  48. }
  49. if (staticProps) {
  50. _defineProperties(Constructor, staticProps)
  51. }
  52. Object.defineProperty(Constructor, "prototype", {
  53. writable: false
  54. });
  55. return Constructor
  56. }
  57. function _get() {
  58. if ("undefined" !== typeof Reflect && Reflect.get) {
  59. _get = Reflect.get.bind()
  60. } else {
  61. _get = function(target, property, receiver) {
  62. var base = _superPropBase(target, property);
  63. if (!base) {
  64. return
  65. }
  66. var desc = Object.getOwnPropertyDescriptor(base, property);
  67. if (desc.get) {
  68. return desc.get.call(arguments.length < 3 ? target : receiver)
  69. }
  70. return desc.value
  71. }
  72. }
  73. return _get.apply(this, arguments)
  74. }
  75. function _superPropBase(object, property) {
  76. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  77. object = _getPrototypeOf(object);
  78. if (null === object) {
  79. break
  80. }
  81. }
  82. return object
  83. }
  84. function _inherits(subClass, superClass) {
  85. if ("function" !== typeof superClass && null !== superClass) {
  86. throw new TypeError("Super expression must either be null or a function")
  87. }
  88. subClass.prototype = Object.create(superClass && superClass.prototype, {
  89. constructor: {
  90. value: subClass,
  91. writable: true,
  92. configurable: true
  93. }
  94. });
  95. Object.defineProperty(subClass, "prototype", {
  96. writable: false
  97. });
  98. if (superClass) {
  99. _setPrototypeOf(subClass, superClass)
  100. }
  101. }
  102. function _setPrototypeOf(o, p) {
  103. _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
  104. o.__proto__ = p;
  105. return o
  106. };
  107. return _setPrototypeOf(o, p)
  108. }
  109. function _createSuper(Derived) {
  110. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  111. return function() {
  112. var result, Super = _getPrototypeOf(Derived);
  113. if (hasNativeReflectConstruct) {
  114. var NewTarget = _getPrototypeOf(this).constructor;
  115. result = Reflect.construct(Super, arguments, NewTarget)
  116. } else {
  117. result = Super.apply(this, arguments)
  118. }
  119. return _possibleConstructorReturn(this, result)
  120. }
  121. }
  122. function _possibleConstructorReturn(self, call) {
  123. if (call && ("object" === _typeof(call) || "function" === typeof call)) {
  124. return call
  125. } else {
  126. if (void 0 !== call) {
  127. throw new TypeError("Derived constructors may only return object or undefined")
  128. }
  129. }
  130. return _assertThisInitialized(self)
  131. }
  132. function _assertThisInitialized(self) {
  133. if (void 0 === self) {
  134. throw new ReferenceError("this hasn't been initialised - super() hasn't been called")
  135. }
  136. return self
  137. }
  138. function _isNativeReflectConstruct() {
  139. if ("undefined" === typeof Reflect || !Reflect.construct) {
  140. return false
  141. }
  142. if (Reflect.construct.sham) {
  143. return false
  144. }
  145. if ("function" === typeof Proxy) {
  146. return true
  147. }
  148. try {
  149. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
  150. return true
  151. } catch (e) {
  152. return false
  153. }
  154. }
  155. function _getPrototypeOf(o) {
  156. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(o) {
  157. return o.__proto__ || Object.getPrototypeOf(o)
  158. };
  159. return _getPrototypeOf(o)
  160. }
  161. var ShrinkStrategy = function(_DrawerStrategy) {
  162. _inherits(ShrinkStrategy, _DrawerStrategy);
  163. var _super = _createSuper(ShrinkStrategy);
  164. function ShrinkStrategy() {
  165. _classCallCheck(this, ShrinkStrategy);
  166. return _super.apply(this, arguments)
  167. }
  168. _createClass(ShrinkStrategy, [{
  169. key: "slidePositionRendering",
  170. value: function(config, offset, animate) {
  171. if (animate) {
  172. var animationConfig = (0, _extend.extend)(config.defaultAnimationConfig, {
  173. $element: config.$panel,
  174. margin: config.panelOffset,
  175. duration: this.getDrawerInstance().option("animationDuration"),
  176. direction: config.direction
  177. });
  178. _uiDrawerRendering.animation.margin(animationConfig)
  179. } else {
  180. config.$panel.css("margin" + (0, _inflector.camelize)(config.direction, true), config.panelOffset)
  181. }
  182. }
  183. }, {
  184. key: "expandPositionRendering",
  185. value: function(config, offset, animate) {
  186. var drawer = this.getDrawerInstance();
  187. if (animate) {
  188. var animationConfig = (0, _extend.extend)(config.defaultAnimationConfig, {
  189. $element: config.$panel,
  190. size: config.size,
  191. duration: drawer.option("animationDuration"),
  192. direction: config.direction
  193. });
  194. _uiDrawerRendering.animation.size(animationConfig)
  195. } else {
  196. if (drawer.isHorizontalDirection()) {
  197. (0, _renderer2.default)(config.$panel).css("width", config.size)
  198. } else {
  199. (0, _renderer2.default)(config.$panel).css("height", config.size)
  200. }
  201. }
  202. }
  203. }, {
  204. key: "getPositionRenderingConfig",
  205. value: function(offset) {
  206. return (0, _extend.extend)(_get(_getPrototypeOf(ShrinkStrategy.prototype), "getPositionRenderingConfig", this).call(this, offset), {
  207. panelOffset: this._getPanelOffset(offset)
  208. })
  209. }
  210. }, {
  211. key: "needOrderContent",
  212. value: function(position, isRtl) {
  213. return (isRtl ? "left" === position : "right" === position) || "bottom" === position
  214. }
  215. }]);
  216. return ShrinkStrategy
  217. }(_uiDrawerRendering2.default);
  218. module.exports = ShrinkStrategy;