@enact/ui 4.6.2 → 4.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AnnounceDecorator/Announce.js +25 -16
- package/AnnounceDecorator/AnnounceDecorator.js +14 -7
- package/AnnounceDecorator/useAnnounce.js +1 -2
- package/BodyText/BodyText.js +14 -8
- package/Button/Button.js +16 -10
- package/Button/tests/Button-specs.js +10 -6
- package/CHANGELOG.md +18 -0
- package/Cancelable/Cancelable.js +13 -7
- package/Changeable/Changeable.js +11 -7
- package/ComponentOverride/ComponentOverride.js +18 -7
- package/FloatingLayer/FloatingLayer.js +10 -11
- package/FloatingLayer/FloatingLayerDecorator.js +9 -6
- package/ForwardRef/ForwardRef.js +11 -7
- package/GridListImageItem/GridListImageItem.js +16 -9
- package/Group/Group.js +17 -8
- package/Group/GroupItem.js +14 -10
- package/Group/tests/Group-specs.js +14 -9
- package/Heading/Heading.js +20 -9
- package/Icon/Icon.js +15 -8
- package/IconButton/IconButton.js +22 -9
- package/Image/Image.js +16 -8
- package/ImageItem/ImageItem.js +9 -1
- package/Item/Item.js +17 -9
- package/Item/tests/Item-specs.js +10 -6
- package/LabeledIcon/LabeledIcon.js +16 -8
- package/Layout/Cell.js +27 -4
- package/Layout/Layout.d.ts +22 -5
- package/Layout/Layout.js +154 -32
- package/Layout/Layout.module.css +8 -0
- package/Layout/tests/Layout-specs.js +39 -0
- package/Marquee/MarqueeController.js +43 -0
- package/Marquee/MarqueeDecorator.js +40 -9
- package/Measurable/Measurable.js +11 -7
- package/Media/Media.js +30 -23
- package/Placeholder/PlaceholderControllerDecorator.js +8 -8
- package/Placeholder/PlaceholderDecorator.js +7 -8
- package/ProgressBar/ProgressBar.js +12 -1
- package/RadioDecorator/RadioDecorator.js +18 -13
- package/RadioDecorator/tests/RadioDecorator-specs.js +28 -20
- package/Repeater/Repeater.js +14 -10
- package/Resizable/Resizable.js +28 -98
- package/Resizable/ResizeContext.js +17 -0
- package/Resizable/tests/useResize-specs.js +43 -0
- package/Resizable/useResize.js +66 -0
- package/Routable/Link.js +8 -8
- package/Routable/Routable.js +15 -8
- package/Routable/Router.js +10 -10
- package/Routable/tests/Routable-specs.js +9 -6
- package/Scrollable/ScrollThumb.js +8 -9
- package/Scrollable/Scrollable.js +23 -7
- package/Scrollable/ScrollableNative.js +19 -14
- package/Scroller/Scroller.js +8 -1
- package/Scroller/ScrollerBasic.js +8 -9
- package/Scroller/UiScrollerBase.js +11 -12
- package/Skinnable/Skinnable.js +19 -7
- package/Skinnable/useSkins.js +1 -2
- package/Slider/Knob.js +8 -8
- package/Slider/Slider.js +16 -9
- package/SlotItem/SlotItem.js +20 -8
- package/Slottable/Slottable.js +14 -8
- package/Spinner/Spinner.js +24 -9
- package/ToggleIcon/ToggleIcon.js +21 -9
- package/ToggleIcon/tests/ToggleIcon-specs.js +6 -3
- package/ToggleItem/ToggleItem.js +14 -1
- package/ToggleItem/tests/ToggleItem-specs.js +6 -3
- package/Toggleable/Toggleable.js +11 -7
- package/Toggleable/useToggle.js +0 -1
- package/Touchable/Drag.js +1 -0
- package/Touchable/Flick.js +1 -0
- package/Touchable/Hold.js +1 -0
- package/Touchable/Pinch.js +1 -0
- package/Touchable/Touch.js +3 -3
- package/Touchable/Touchable.js +7 -0
- package/Touchable/useTouch.js +0 -1
- package/Transition/Transition.js +19 -3
- package/ViewManager/Arranger.js +4 -1
- package/ViewManager/TransitionGroup.js +5 -4
- package/ViewManager/View.js +12 -12
- package/ViewManager/ViewManager.js +25 -9
- package/ViewManager/tests/ViewManager-specs.js +44 -0
- package/VirtualList/UiVirtualListBase.js +3 -4
- package/VirtualList/VirtualList.js +11 -1
- package/VirtualList/VirtualListBasic.js +4 -4
- package/internal/IdProvider/IdProvider.js +6 -7
- package/internal/IdProvider/useId.js +0 -1
- package/internal/Pure/Pure.js +11 -7
- package/package.json +3 -3
- package/resolution/ResolutionDecorator.js +36 -7
- package/resolution/resolution.js +23 -7
- package/useScroll/ScrollbarTrack.js +8 -8
- package/useScroll/useScroll.js +17 -1
package/Touchable/Touchable.js
CHANGED
|
@@ -28,6 +28,13 @@ var _Pinch = require("./Pinch");
|
|
|
28
28
|
var _useTouch = _interopRequireDefault(require("./useTouch"));
|
|
29
29
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
30
30
|
var _excluded = ["dragConfig", "flickConfig", "holdConfig", "pinchConfig", "disabled", "noResume", "onBlur", "onClick", "onMouseDown", "onMouseEnter", "onMouseLeave", "onMouseMove", "onMouseUp", "onTouchEnd", "onTouchMove", "onTouchStart", "onDown", "onDrag", "onDragEnd", "onDragStart", "onFlick", "onHold", "onHoldEnd", "onHoldStart", "onMove", "onPinch", "onPinchEnd", "onPinchStart", "onTap", "onUp"];
|
|
31
|
+
/**
|
|
32
|
+
* Application support for gestures.
|
|
33
|
+
*
|
|
34
|
+
* @module ui/Touchable
|
|
35
|
+
* @exports Touchable
|
|
36
|
+
* @exports configure
|
|
37
|
+
*/
|
|
31
38
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
32
39
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
33
40
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
package/Touchable/useTouch.js
CHANGED
|
@@ -70,7 +70,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
70
70
|
* @property {Object} handlers Event handlers that need to be passed to DOM node
|
|
71
71
|
* @private
|
|
72
72
|
*/
|
|
73
|
-
|
|
74
73
|
/**
|
|
75
74
|
* Provides a consistent set of pointer events -- `onDown`, `onUp`, and `onTap` --
|
|
76
75
|
* across mouse and touch interfaces along with support for common gestures including
|
package/Transition/Transition.js
CHANGED
|
@@ -32,7 +32,23 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
32
32
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
33
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
34
34
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
35
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
35
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
|
|
36
|
+
* A component that can transition its children components onto the screen.
|
|
37
|
+
*
|
|
38
|
+
* Transitions whether that's from off the edge of the screen or hidden inside or behind an
|
|
39
|
+
* already-on-screen component. You can switch types of transitions using the `type` property,
|
|
40
|
+
* change the direction they come in from using the `direction` property, or even adjust the
|
|
41
|
+
* transition timing function using `timingFunction`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* <Transition visible={true} type="slide">
|
|
45
|
+
* <div>Set `visible` above to `false` to hide this element.</div>
|
|
46
|
+
* </Transition>
|
|
47
|
+
*
|
|
48
|
+
* @module ui/Transition
|
|
49
|
+
* @exports Transition
|
|
50
|
+
* @exports TransitionBase
|
|
51
|
+
*/
|
|
36
52
|
var formatter = function formatter(duration) {
|
|
37
53
|
return typeof duration === 'number' ? duration + 'ms' : duration;
|
|
38
54
|
};
|
|
@@ -399,9 +415,9 @@ var Transition = /*#__PURE__*/function (_Component) {
|
|
|
399
415
|
}
|
|
400
416
|
if (noAnimation) {
|
|
401
417
|
if (!prevProps.visible && visible) {
|
|
402
|
-
(0, _handle.forwardCustom)('onShow')(
|
|
418
|
+
(0, _handle.forwardCustom)('onShow')(null, this.props);
|
|
403
419
|
} else if (prevProps.visible && !visible) {
|
|
404
|
-
(0, _handle.forwardCustom)('onHide')(
|
|
420
|
+
(0, _handle.forwardCustom)('onHide')(null, this.props);
|
|
405
421
|
}
|
|
406
422
|
}
|
|
407
423
|
}
|
package/ViewManager/Arranger.js
CHANGED
|
@@ -10,7 +10,10 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
10
10
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
11
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
12
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
13
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
14
|
+
* Exports a number of pre-defined arrangers for use with {@link ui/ViewManager}.
|
|
15
|
+
* note: not jsdoc on purpose
|
|
16
|
+
*/
|
|
14
17
|
var slideInOut = function slideInOut(direction, total, orientation) {
|
|
15
18
|
var p = direction === 'out' ? total : -total;
|
|
16
19
|
return orientation === 'top' && 'translateY(' + -p + '%)' || orientation === 'bottom' && 'translateY(' + p + '%)' || orientation === 'left' && 'translateX(' + -p + '%)' || orientation === 'right' && 'translateX(' + p + '%)';
|
|
@@ -28,7 +28,9 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
28
28
|
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
29
29
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
30
30
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
31
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /*
|
|
32
|
+
* Exports the {@link ui/ViewManager.TransitionGroup} component.
|
|
33
|
+
*/ // Using string refs from the source code of ReactTransitionGroup
|
|
32
34
|
/**
|
|
33
35
|
* Returns the index of a child in an array found by `key` matching
|
|
34
36
|
*
|
|
@@ -37,8 +39,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
37
39
|
* @returns {Number} Index of child
|
|
38
40
|
* @method
|
|
39
41
|
* @private
|
|
40
|
-
*/
|
|
41
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
42
|
+
*/ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
42
43
|
var indexOfChild = (0, _useWith["default"])(_findIndex["default"], [(0, _propEq["default"])('key'), _identity["default"]]);
|
|
43
44
|
|
|
44
45
|
/**
|
|
@@ -405,7 +406,7 @@ TransitionGroup.propTypes = /** @lends ui/ViewManager.TransitionGroup.prototype
|
|
|
405
406
|
*/
|
|
406
407
|
component: _propTypes["default"].renderable,
|
|
407
408
|
/**
|
|
408
|
-
* Called with a reference to {@link ui/ViewManager.TransitionGroup
|
|
409
|
+
* Called with a reference to {@link ui/ViewManager.TransitionGroup.component|component}
|
|
409
410
|
*
|
|
410
411
|
* @type {Object|Function}
|
|
411
412
|
* @private
|
package/ViewManager/View.js
CHANGED
|
@@ -25,8 +25,9 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
25
25
|
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
26
26
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
27
27
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
28
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
29
|
-
|
|
28
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /*
|
|
29
|
+
* Exports the {@link ui/ViewManager.View} component.
|
|
30
|
+
*/ // If the View was "appearing", then entering will always be false and this will not result in a
|
|
30
31
|
// re-render. If the view should enter, state.enter will be true and this will toggle it to false
|
|
31
32
|
// causing a re-render.
|
|
32
33
|
var clearEntering = function clearEntering(_ref) {
|
|
@@ -54,6 +55,15 @@ var View = /*#__PURE__*/function (_Component) {
|
|
|
54
55
|
_this.enteringJob = new _util.Job(function () {
|
|
55
56
|
_this.setState(clearEntering);
|
|
56
57
|
});
|
|
58
|
+
/**
|
|
59
|
+
* Initiates a new transition
|
|
60
|
+
*
|
|
61
|
+
* @param {Function} arranger Arranger function to call (enter, leave)
|
|
62
|
+
* @param {Function} callback Completion callback
|
|
63
|
+
* @param {Boolean} [noAnimation] `true` to disable animation for this transition
|
|
64
|
+
* @returns {undefined}
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
57
67
|
_this.prepareTransition = function (arranger, callback, noAnimation) {
|
|
58
68
|
var _this$props = _this.props,
|
|
59
69
|
duration = _this$props.duration,
|
|
@@ -214,16 +224,6 @@ var View = /*#__PURE__*/function (_Component) {
|
|
|
214
224
|
callback();
|
|
215
225
|
}
|
|
216
226
|
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Initiates a new transition
|
|
220
|
-
*
|
|
221
|
-
* @param {Function} arranger Arranger function to call (enter, leave)
|
|
222
|
-
* @param {Function} callback Completion callback
|
|
223
|
-
* @param {Boolean} [noAnimation] `true` to disable animation for this transition
|
|
224
|
-
* @returns {undefined}
|
|
225
|
-
* @private
|
|
226
|
-
*/
|
|
227
227
|
}, {
|
|
228
228
|
key: "render",
|
|
229
229
|
value: function render() {
|
|
@@ -31,6 +31,29 @@ var _View = require("./View");
|
|
|
31
31
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
32
32
|
var _excluded = ["arranger", "childProps", "children", "duration", "index", "noAnimation", "enteringDelay", "enteringProp", "rtl"];
|
|
33
33
|
var _class;
|
|
34
|
+
/**
|
|
35
|
+
* A component that manages the transitions of views.
|
|
36
|
+
*
|
|
37
|
+
* @module ui/ViewManager
|
|
38
|
+
* @exports shape
|
|
39
|
+
* @exports SlideArranger
|
|
40
|
+
* @exports SlideBottomArranger
|
|
41
|
+
* @exports SlideLeftArranger
|
|
42
|
+
* @exports SlideRightArranger
|
|
43
|
+
* @exports SlideTopArranger
|
|
44
|
+
* @exports ViewManager
|
|
45
|
+
* @exports ViewManagerBase
|
|
46
|
+
* @exports ViewManagerDecorator
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* The base `ViewManager` component, without
|
|
50
|
+
* {@link ui/ViewManager.ViewManagerDecorator|ViewManagerDecorator} applied.
|
|
51
|
+
*
|
|
52
|
+
* @class ViewManagerBase
|
|
53
|
+
* @memberof ui/ViewManager
|
|
54
|
+
* @ui
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
34
57
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
58
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
36
59
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -51,15 +74,6 @@ function _possibleConstructorReturn(self, call) { if (call && (typeof call === "
|
|
|
51
74
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
52
75
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
53
76
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
54
|
-
/**
|
|
55
|
-
* The base `ViewManager` component, without
|
|
56
|
-
* {@link ui/ViewManager.ViewManagerDecorator|ViewManagerDecorator} applied.
|
|
57
|
-
*
|
|
58
|
-
* @class ViewManagerBase
|
|
59
|
-
* @memberof ui/ViewManager
|
|
60
|
-
* @ui
|
|
61
|
-
* @public
|
|
62
|
-
*/
|
|
63
77
|
var ViewManagerBase = (_class = /*#__PURE__*/function (_Component) {
|
|
64
78
|
_inherits(ViewManagerBase, _Component);
|
|
65
79
|
var _super = _createSuper(ViewManagerBase);
|
|
@@ -138,6 +152,8 @@ var ViewManagerBase = (_class = /*#__PURE__*/function (_Component) {
|
|
|
138
152
|
value: function getDerivedStateFromProps(props, state) {
|
|
139
153
|
if (props.reverseTransition != null) {
|
|
140
154
|
return {
|
|
155
|
+
index: props.index,
|
|
156
|
+
prevIndex: state.index,
|
|
141
157
|
reverseTransition: !!props.reverseTransition
|
|
142
158
|
};
|
|
143
159
|
} else if (props.index !== state.index) {
|
|
@@ -4,6 +4,7 @@ require("@testing-library/jest-dom");
|
|
|
4
4
|
var _react = require("@testing-library/react");
|
|
5
5
|
var _react2 = require("react");
|
|
6
6
|
var _ = _interopRequireDefault(require("../"));
|
|
7
|
+
var _Arranger = require("../Arranger");
|
|
7
8
|
var _testUtils = require("./test-utils");
|
|
8
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -837,4 +838,47 @@ describe('ViewManager', function () {
|
|
|
837
838
|
expect(actual).toMatchObject(expected);
|
|
838
839
|
spy.mockRestore();
|
|
839
840
|
});
|
|
841
|
+
test('should not remove view immediately after `index` change if an arranger is present even for multiple views', function () {
|
|
842
|
+
var _render19 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
843
|
+
arranger: _Arranger.SlideTopArranger,
|
|
844
|
+
"data-testid": "viewManager",
|
|
845
|
+
end: 2,
|
|
846
|
+
index: 0,
|
|
847
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
848
|
+
children: "View 1"
|
|
849
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
850
|
+
children: "View 2"
|
|
851
|
+
}, "view2"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
852
|
+
children: "View 3"
|
|
853
|
+
}, "view3"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
854
|
+
children: "View 4"
|
|
855
|
+
}, "view4"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
856
|
+
children: "View 5"
|
|
857
|
+
}, "view5")]
|
|
858
|
+
})),
|
|
859
|
+
rerender = _render19.rerender;
|
|
860
|
+
var actual = _react.screen.getByTestId('viewManager').children.length;
|
|
861
|
+
var expected = 3;
|
|
862
|
+
expect(actual).toBe(expected);
|
|
863
|
+
rerender( /*#__PURE__*/(0, _jsxRuntime.jsxs)(_["default"], {
|
|
864
|
+
arranger: _Arranger.SlideTopArranger,
|
|
865
|
+
"data-testid": "viewManager",
|
|
866
|
+
end: 3,
|
|
867
|
+
index: 1,
|
|
868
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
869
|
+
children: "View 1"
|
|
870
|
+
}, "view1"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
871
|
+
children: "View 2"
|
|
872
|
+
}, "view2"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
873
|
+
children: "View 3"
|
|
874
|
+
}, "view3"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
875
|
+
children: "View 4"
|
|
876
|
+
}, "view4"), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
877
|
+
children: "View 5"
|
|
878
|
+
}, "view5")]
|
|
879
|
+
}));
|
|
880
|
+
actual = _react.screen.getByTestId('viewManager').children.length;
|
|
881
|
+
expected = 4;
|
|
882
|
+
expect(actual).toBe(expected);
|
|
883
|
+
});
|
|
840
884
|
});
|
|
@@ -59,8 +59,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
|
|
|
59
59
|
return _class = /*#__PURE__*/function (_Component) {
|
|
60
60
|
_inherits(VirtualListCore, _Component);
|
|
61
61
|
var _super = _createSuper(VirtualListCore);
|
|
62
|
-
/* No displayName here. We set displayName to returned components of this factory function. */
|
|
63
|
-
|
|
64
62
|
function VirtualListCore(_props) {
|
|
65
63
|
var _this;
|
|
66
64
|
_classCallCheck(this, VirtualListCore);
|
|
@@ -91,6 +89,7 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
|
|
|
91
89
|
_this.cc = [];
|
|
92
90
|
_this.scrollPosition = 0;
|
|
93
91
|
_this.scrollPositionTarget = 0;
|
|
92
|
+
// For individually sized item
|
|
94
93
|
_this.itemPositions = [];
|
|
95
94
|
_this.indexToScrollIntoView = -1;
|
|
96
95
|
_this.updateScrollPosition = function (_ref) {
|
|
@@ -115,6 +114,7 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
|
|
|
115
114
|
_this.getMoreInfo = function () {
|
|
116
115
|
return _this.moreInfo;
|
|
117
116
|
};
|
|
117
|
+
// For individually sized item
|
|
118
118
|
_this.getItemBottomPosition = function (index) {
|
|
119
119
|
var itemPosition = _this.itemPositions[index],
|
|
120
120
|
itemSize = _this.props.itemSizes[index];
|
|
@@ -124,6 +124,7 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
|
|
|
124
124
|
return index * _this.primary.gridSize - _this.props.spacing;
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
|
+
// For individually sized item
|
|
127
128
|
_this.getItemTopPositionFromPreviousItemBottomPosition = function (index, spacing) {
|
|
128
129
|
return index === 0 ? 0 : _this.getItemBottomPosition(index - 1) + spacing;
|
|
129
130
|
};
|
|
@@ -451,8 +452,6 @@ var VirtualListBaseFactory = function VirtualListBaseFactory(type) {
|
|
|
451
452
|
secondaryPosition: secondaryPosition
|
|
452
453
|
};
|
|
453
454
|
}
|
|
454
|
-
|
|
455
|
-
// For individually sized item
|
|
456
455
|
}, {
|
|
457
456
|
key: "emitUpdateItems",
|
|
458
457
|
value: function emitUpdateItems() {
|
|
@@ -47,7 +47,17 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
47
47
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
48
48
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
49
49
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
50
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
50
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
|
|
51
|
+
* Unstyled virtual list components and behaviors to be customized by a theme or application.
|
|
52
|
+
*
|
|
53
|
+
* @module ui/VirtualList
|
|
54
|
+
* @exports gridListImageSizeShape
|
|
55
|
+
* @exports itemSizesShape
|
|
56
|
+
* @exports VirtualGridList
|
|
57
|
+
* @exports VirtualList
|
|
58
|
+
* @exports VirtualListBase
|
|
59
|
+
* @exports VirtualListBasic
|
|
60
|
+
*/
|
|
51
61
|
var nop = function nop() {};
|
|
52
62
|
|
|
53
63
|
/**
|
|
@@ -117,6 +117,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
117
117
|
_this.scrollPosition = 0;
|
|
118
118
|
_this.scrollPositionTarget = 0;
|
|
119
119
|
_this.scrollToPositionTarget = -1;
|
|
120
|
+
// For individually sized item
|
|
120
121
|
_this.itemPositions = [];
|
|
121
122
|
_this.indexToScrollIntoView = -1;
|
|
122
123
|
_this.updateScrollPosition = function (_ref, behavior) {
|
|
@@ -144,6 +145,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
144
145
|
_this.getCenterItemIndexFromScrollPosition = function (scrollPosition) {
|
|
145
146
|
return Math.floor((scrollPosition + _this.primary.clientSize / 2) / _this.primary.gridSize) * _this.dimensionToExtent + Math.floor(_this.dimensionToExtent / 2);
|
|
146
147
|
};
|
|
148
|
+
// For individually sized item
|
|
147
149
|
_this.getItemBottomPosition = function (index) {
|
|
148
150
|
var itemPosition = _this.itemPositions[index],
|
|
149
151
|
itemSize = _this.props.itemSizes[index];
|
|
@@ -153,6 +155,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
153
155
|
return index * _this.primary.gridSize - _this.props.spacing;
|
|
154
156
|
}
|
|
155
157
|
};
|
|
158
|
+
// For individually sized item
|
|
156
159
|
_this.getItemTopPositionFromPreviousItemBottomPosition = function (index, spacing) {
|
|
157
160
|
return index === 0 ? 0 : _this.getItemBottomPosition(index - 1) + spacing;
|
|
158
161
|
};
|
|
@@ -251,6 +254,7 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
251
254
|
_this.contentRef.current.style.height = _this.scrollBounds.scrollHeight + (_this.isPrimaryDirectionVertical ? 0 : -1) + 'px';
|
|
252
255
|
}
|
|
253
256
|
};
|
|
257
|
+
// scrollMode 'native' only
|
|
254
258
|
_this.getRtlPositionX = function (x) {
|
|
255
259
|
if (_this.props.rtl) {
|
|
256
260
|
return _platform.platform.ios || _platform.platform.safari || _platform.platform.chrome >= 85 || _platform.platform.androidChrome >= 85 ? -x : _this.scrollBounds.maxLeft - x;
|
|
@@ -508,8 +512,6 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
508
512
|
secondaryPosition: secondaryPosition
|
|
509
513
|
};
|
|
510
514
|
}
|
|
511
|
-
|
|
512
|
-
// For individually sized item
|
|
513
515
|
}, {
|
|
514
516
|
key: "emitUpdateItems",
|
|
515
517
|
value: function emitUpdateItems() {
|
|
@@ -717,8 +719,6 @@ var VirtualListBasic = /*#__PURE__*/function (_Component) {
|
|
|
717
719
|
}
|
|
718
720
|
}
|
|
719
721
|
}
|
|
720
|
-
|
|
721
|
-
// scrollMode 'native' only
|
|
722
722
|
}, {
|
|
723
723
|
key: "scrollToPosition",
|
|
724
724
|
value:
|
|
@@ -18,13 +18,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
18
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
19
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20
20
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
21
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*/
|
|
21
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /**
|
|
22
|
+
* Default config for {@link ui/IdProvider.IdProvider}
|
|
23
|
+
*
|
|
24
|
+
* @hocconfig
|
|
25
|
+
* @memberof ui/IdProvider.IdProvider
|
|
26
|
+
*/
|
|
28
27
|
var defaultConfig = {
|
|
29
28
|
/**
|
|
30
29
|
* Prop to pass the identifier generation function
|
package/internal/Pure/Pure.js
CHANGED
|
@@ -22,13 +22,17 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
22
22
|
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
23
23
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
24
24
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
25
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /**
|
|
26
|
+
* Exports the {@link ui/internal/Pure.Pure} higher-order component (HOC).
|
|
27
|
+
*
|
|
28
|
+
* @module ui/internal/Pure
|
|
29
|
+
* @private
|
|
30
|
+
*/ /**
|
|
31
|
+
* Default config for {@link ui/internal/Pure.Pure}.
|
|
32
|
+
*
|
|
33
|
+
* @memberof ui/internal/Pure.Pure
|
|
34
|
+
* @hocconfig
|
|
35
|
+
*/
|
|
32
36
|
var defaultConfig = {
|
|
33
37
|
/**
|
|
34
38
|
* Configures the comparators used to test for prop changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enact/ui",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.1",
|
|
4
4
|
"description": "A collection of simplified unstyled cross-platform UI components for Enact",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@enact/core": "^4.
|
|
34
|
+
"@enact/core": "^4.7.1",
|
|
35
35
|
"classnames": "^2.3.2",
|
|
36
36
|
"direction": "^1.0.4",
|
|
37
37
|
"invariant": "^2.2.4",
|
|
38
38
|
"prop-types": "^15.8.1",
|
|
39
|
-
"ramda": "^0.
|
|
39
|
+
"ramda": "^0.29.0",
|
|
40
40
|
"react": "^18.2.0",
|
|
41
41
|
"react-dom": "^18.2.0",
|
|
42
42
|
"react-is": "^18.2.0",
|
|
@@ -25,13 +25,16 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
25
25
|
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
26
26
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
27
27
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
28
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } /*
|
|
29
|
+
* Exports the {@link ui/resolution.ResolutionDecorator} higher-order component (HOC).
|
|
30
|
+
*
|
|
31
|
+
* not jsdoc module on purpose
|
|
32
|
+
*/ /**
|
|
33
|
+
* Default config for `ResolutionDecorator`.
|
|
34
|
+
*
|
|
35
|
+
* @memberof ui/resolution.ResolutionDecorator
|
|
36
|
+
* @hocconfig
|
|
37
|
+
*/
|
|
35
38
|
var defaultConfig = {
|
|
36
39
|
/**
|
|
37
40
|
* Attaches an event listener to the window to listen for resize events.
|
|
@@ -42,6 +45,30 @@ var defaultConfig = {
|
|
|
42
45
|
* @memberof ui/resolution.ResolutionDecorator.defaultConfig
|
|
43
46
|
*/
|
|
44
47
|
dynamic: true,
|
|
48
|
+
/**
|
|
49
|
+
* Determines how to calculate font-size.
|
|
50
|
+
* When set to `scale` and the screen is in `landscape` orientation,
|
|
51
|
+
* calculates font-size linearly based on screen resolution.
|
|
52
|
+
* When set to `normal`, the font-size will be the pxPerRem value of the best match screen type.
|
|
53
|
+
*
|
|
54
|
+
* @type {('normal'|'scale')}
|
|
55
|
+
* @default 'normal'
|
|
56
|
+
* @private
|
|
57
|
+
* @memberof ui/resolution.ResolutionDecorator.defaultConfig
|
|
58
|
+
*/
|
|
59
|
+
intermediateScreenHandling: 'normal',
|
|
60
|
+
/**
|
|
61
|
+
* Determines how to get the best match screen type of current resolution.
|
|
62
|
+
* When set to `true`, the matched screen type will be the one that is smaller and
|
|
63
|
+
* the closest to the screen resolution.
|
|
64
|
+
* When set to `false`, the matched screen type will be the one that is greater and
|
|
65
|
+
* the closest to the screen resolution.
|
|
66
|
+
*
|
|
67
|
+
* @type {Boolean}
|
|
68
|
+
* @private
|
|
69
|
+
* @memberof ui/resolution.ResolutionDecorator.defaultConfig
|
|
70
|
+
*/
|
|
71
|
+
matchSmallerScreenType: false,
|
|
45
72
|
/**
|
|
46
73
|
* An array of objects containing declarations for screen types to add to the list of known
|
|
47
74
|
* screen types.
|
|
@@ -96,6 +123,8 @@ var ResolutionDecorator = (0, _hoc["default"])(defaultConfig, function (config,
|
|
|
96
123
|
});
|
|
97
124
|
}
|
|
98
125
|
};
|
|
126
|
+
_resolution.config.intermediateScreenHandling = config.intermediateScreenHandling;
|
|
127
|
+
_resolution.config.matchSmallerScreenType = config.matchSmallerScreenType;
|
|
99
128
|
(0, _resolution.init)({
|
|
100
129
|
measurementNode: typeof window !== 'undefined' && window
|
|
101
130
|
});
|
package/resolution/resolution.js
CHANGED
|
@@ -51,6 +51,8 @@ var unitToPixelFactors = {
|
|
|
51
51
|
};
|
|
52
52
|
exports.unitToPixelFactors = unitToPixelFactors;
|
|
53
53
|
var configDefaults = {
|
|
54
|
+
intermediateScreenHandling: 'normal',
|
|
55
|
+
matchSmallerScreenType: false,
|
|
54
56
|
orientationHandling: 'normal'
|
|
55
57
|
};
|
|
56
58
|
|
|
@@ -160,7 +162,7 @@ function defineScreenTypes(types) {
|
|
|
160
162
|
function getScreenType(rez) {
|
|
161
163
|
rez = rez || workspaceBounds;
|
|
162
164
|
var types = screenTypes;
|
|
163
|
-
var bestMatch = types[types.length - 1].name; // Blindly set the first screen type, in case no matches are found later.
|
|
165
|
+
var bestMatch = config.matchSmallerScreenType ? types[0].name : types[types.length - 1].name; // Blindly set the first screen type, in case no matches are found later.
|
|
164
166
|
|
|
165
167
|
orientation = 'landscape';
|
|
166
168
|
if (rez.height > rez.width) {
|
|
@@ -169,14 +171,24 @@ function getScreenType(rez) {
|
|
|
169
171
|
rez.width = rez.height;
|
|
170
172
|
rez.height = swap;
|
|
171
173
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
if (config.matchSmallerScreenType) {
|
|
175
|
+
// Loop through resolutions, first->last, smallest->largest
|
|
176
|
+
for (var i = 0; i <= types.length - 1; i++) {
|
|
177
|
+
// Does this screenType definition fit inside the current resolution? If so, save it as the current best match.
|
|
178
|
+
if (rez.height >= types[i].height && rez.width >= types[i].width) {
|
|
179
|
+
bestMatch = types[i].name;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
// Loop through resolutions, last->first, largest->smallest
|
|
184
|
+
for (var _i = types.length - 1; _i >= 0; _i--) {
|
|
185
|
+
// Does the current resolution fit inside this screenType definition? If so, save it as the current best match.
|
|
186
|
+
if (rez.height <= types[_i].height && rez.width <= types[_i].width) {
|
|
187
|
+
bestMatch = types[_i].name;
|
|
188
|
+
}
|
|
178
189
|
}
|
|
179
190
|
}
|
|
191
|
+
|
|
180
192
|
// Return the name of the closest fitting set of dimensions.
|
|
181
193
|
return bestMatch;
|
|
182
194
|
}
|
|
@@ -208,11 +220,15 @@ function getScreenType(rez) {
|
|
|
208
220
|
*/
|
|
209
221
|
function calculateFontSize(type) {
|
|
210
222
|
var scrObj = getScreenTypeObject(type);
|
|
223
|
+
var shouldScaleFontSize = config.intermediateScreenHandling === 'scale' && (config.matchSmallerScreenType ? workspaceBounds.width > scrObj.width && workspaceBounds.height > scrObj.height : workspaceBounds.width < scrObj.width && workspaceBounds.height < scrObj.height);
|
|
211
224
|
var size;
|
|
212
225
|
if (orientation === 'portrait' && config.orientationHandling === 'scale') {
|
|
213
226
|
size = scrObj.height / scrObj.width * scrObj.pxPerRem;
|
|
214
227
|
} else {
|
|
215
228
|
size = scrObj.pxPerRem;
|
|
229
|
+
if (orientation === 'landscape' && shouldScaleFontSize) {
|
|
230
|
+
size = parseInt(workspaceBounds.height * scrObj.pxPerRem / scrObj.height);
|
|
231
|
+
}
|
|
216
232
|
}
|
|
217
233
|
return size + 'px';
|
|
218
234
|
}
|