<NME> trinsicLifecycle.ts
<BEF> ADDFILE
<MSG> trinsic lifecylce

<DFF> @@ -0,0 +1,18 @@
+import { style } from 'support';
+import { LifecycleHub, Lifecycle } from 'lifecycles/lifecycleHub';
+
+export const createTrinsicLifecycle = (lifecycleHub: LifecycleHub): Lifecycle => {
+  const { _structureSetup } = lifecycleHub;
+  const { _content } = _structureSetup._targetObj;
+
+  return (updateHints) => {
+    const { _heightIntrinsic } = updateHints;
+    const { _value: heightIntrinsic, _changed: heightIntrinsicChanged } = _heightIntrinsic;
+
+    if (heightIntrinsicChanged) {
+      style(_content, {
+        height: heightIntrinsic ? 'auto' : '100%',
+      });
+    }
+  };
+};

{'commit': 'diff --git a/packages/overlayscrollbars/src/lifecycles/lifecycleHub.ts b/packages/overlayscrollbars/src/lifecycles/lifecycleHub.ts\nindex 87b5382..bc6f423 100644\n--- a/packages/overlayscrollbars/src/lifecycles/lifecycleHub.ts\n+++ b/packages/overlayscrollbars/src/lifecycles/lifecycleHub.ts\n@@ -2,6 +2,7 @@ import { XY, TRBL, CacheValues, each, push, keys, OptionsValidated, hasOwnProper\n import { Options } from \'options\';\n import { getEnvironment } from \'environment\';\n import { StructureSetup } from \'setups/structureSetup\';\n+import { createTrinsicLifecycle } from \'lifecycles/trinsicLifecycle\';\n import { createPaddingLifecycle } from \'lifecycles/paddingLifecycle\';\n import { createOverflowLifecycle } from \'lifecycles/overflowLifecycle\';\n import { createSizeObserver } from \'observers/sizeObserver\';\n@@ -136,7 +137,7 @@ export const createLifecycleHub = (options: Options, structureSetup: StructureSe\n     },\n   };\n \n-  // push(lifecycles, createStructureLifecycle(instance));\n+  push(lifecycles, createTrinsicLifecycle(instance));\n   push(lifecycles, createPaddingLifecycle(instance));\n   push(lifecycles, createOverflowLifecycle(instance));\n \n@@ -228,8 +229,8 @@ export const createLifecycleHub = (options: Options, structureSetup: StructureSe\n     });\n   };\n \n+  const trinsicObserver = _content ? createTrinsicObserver(_host, onTrinsicChanged) : null;\n   const sizeObserver = createSizeObserver(_host, onSizeChanged, { _appear: true, _direction: !_nativeScrollbarStyling });\n-  const trinsicObserver = createTrinsicObserver(_host, onTrinsicChanged);\n   const hostMutationObserver = createDOMObserver(_host, onHostMutation, {\n     _styleChangingAttributes: attrs,\n     _attributes: attrs,\ndiff --git a/packages/overlayscrollbars/src/lifecycles/structureLifecycle.ts b/packages/overlayscrollbars/src/lifecycles/structureLifecycle.ts\ndeleted file mode 100644\nindex 31ca241..0000000\n--- a/packages/overlayscrollbars/src/lifecycles/structureLifecycle.ts\n+++ /dev/null\n@@ -1,142 +0,0 @@\n-import {\n-  CacheValues,\n-  cssProperty,\n-  runEach,\n-  createCache,\n-  topRightBottomLeft,\n-  TRBL,\n-  WH,\n-  XY,\n-  equalTRBL,\n-  equalXY,\n-  style,\n-  scrollSize,\n-  offsetSize,\n-} from \'support\';\n-import { createLifecycleUpdateFunction } from \'lifecycles/lifecycleUpdateFunction\';\n-import { LifecycleHub } from \'lifecycles/lifecycleHub\';\n-import { getEnvironment, Environment } from \'environment\';\n-\n-const cssMarginEnd = cssProperty(\'margin-inline-end\');\n-const cssBorderEnd = cssProperty(\'border-inline-end\');\n-\n-export const createStructureLifecycle = (lifecycleHub: LifecycleHub): Lifecycle => {\n-  const { _host, _padding, _viewport, _content } = lifecycleHub._structureSetup._targetObj;\n-  const destructFns: (() => any)[] = [];\n-  const env: Environment = getEnvironment();\n-  const scrollbarsOverlaid = env._nativeScrollbarIsOverlaid;\n-  const supportsScrollbarStyling = env._nativeScrollbarStyling;\n-  const supportFlexboxGlue = env._flexboxGlue;\n-  // direction change is only needed to update scrollbar hiding, therefore its not needed if css can do it, scrollbars are invisible or overlaid on y axis\n-  const directionObserverObsolete = (cssMarginEnd && cssBorderEnd) || supportsScrollbarStyling || scrollbarsOverlaid.y;\n-\n-  const { _update: updatePaddingCache } = createCache(() => topRightBottomLeft(_host, \'padding\'), { _equal: equalTRBL });\n-  const { _update: updateOverflowAmountCache } = createCache<XY<number>, { _contentScrollSize: WH<number>; _viewportSize: WH<number> }>(\n-    (ctx) => ({\n-      x: Math.max(0, Math.round((ctx!._contentScrollSize.w - ctx!._viewportSize.w) * 100) / 100),\n-      y: Math.max(0, Math.round((ctx!._contentScrollSize.h - ctx!._viewportSize.h) * 100) / 100),\n-    }),\n-    { _equal: equalXY }\n-  );\n-\n-  const _update = createLifecycleUpdateFunction(lifecycleHub, (force, checkOption) => {\n-    const { _value: paddingAbsolute, _changed: paddingAbsoluteChanged } = checkOption(\'paddingAbsolute\');\n-    const { _value: padding, _changed: paddingChanged } = updatePaddingCache(force);\n-\n-    if (paddingAbsoluteChanged || paddingChanged) {\n-      const paddingStyle: TRBL = {\n-        t: 0,\n-        r: 0,\n-        b: 0,\n-        l: 0,\n-      };\n-\n-      if (!paddingAbsolute) {\n-        paddingStyle.t = -padding!.t;\n-        paddingStyle.r = -(padding!.r + padding!.l);\n-        paddingStyle.b = -(padding!.b + padding!.t);\n-        paddingStyle.l = -padding!.l;\n-      }\n-\n-      style(_padding, {\n-        top: paddingStyle.t,\n-        left: paddingStyle.l,\n-        marginRight: paddingStyle.r,\n-        marginBottom: paddingStyle.b,\n-        maxWidth: `calc(100% + ${paddingStyle.r * -1}px)`,\n-      });\n-    }\n-\n-    const viewportOffsetSize = offsetSize(_padding);\n-    const contentClientSize = offsetSize(_content);\n-    const contentScrollSize = scrollSize(_content);\n-    const overflowAmuntCache = updateOverflowAmountCache(force, {\n-      _contentScrollSize: contentScrollSize,\n-      _viewportSize: {\n-        w: viewportOffsetSize.w + Math.max(0, contentClientSize.w - contentScrollSize.w),\n-        h: viewportOffsetSize.h + Math.max(0, contentClientSize.h - contentScrollSize.h),\n-      },\n-    });\n-    const { _value: overflowAmount, _changed: overflowAmountChanged } = overflowAmuntCache;\n-\n-    console.log(\'overflowAmount\', overflowAmount);\n-    console.log(\'overflowAmountChanged\', overflowAmountChanged);\n-\n-    /*\n-    var setOverflowVariables = function (horizontal) {\n-      var scrollbarVars = getScrollbarVars(horizontal);\n-      var scrollbarVarsInverted = getScrollbarVars(!horizontal);\n-      var xyI = scrollbarVarsInverted._x_y;\n-      var xy = scrollbarVars._x_y;\n-      var wh = scrollbarVars._w_h;\n-      var widthHeight = scrollbarVars._width_height;\n-      var scrollMax = _strScroll + scrollbarVars._Left_Top + \'Max\';\n-      var fractionalOverflowAmount = viewportRect[widthHeight] ? MATH.abs(viewportRect[widthHeight] - _viewportSize[wh]) : 0;\n-      var checkFractionalOverflowAmount = previousOverflowAmount && previousOverflowAmount[xy] > 0 && _viewportElementNative[scrollMax] === 0;\n-      overflowBehaviorIsVS[xy] = overflowBehavior[xy] === \'v-s\';\n-      overflowBehaviorIsVH[xy] = overflowBehavior[xy] === \'v-h\';\n-      overflowBehaviorIsS[xy] = overflowBehavior[xy] === \'s\';\n-      overflowAmount[xy] = MATH.max(0, MATH.round((contentScrollSize[wh] - _viewportSize[wh]) * 100) / 100);\n-      overflowAmount[xy] *=\n-        hideOverflowForceTextarea || (checkFractionalOverflowAmount && fractionalOverflowAmount > 0 && fractionalOverflowAmount < 1) ? 0 : 1;\n-      hasOverflow[xy] = overflowAmount[xy] > 0;\n-\n-      //hideOverflow:\n-      //x || y : true === overflow is hidden by "overflow: scroll" OR "overflow: hidden"\n-      //xs || ys : true === overflow is hidden by "overflow: scroll"\n-      hideOverflow[xy] =\n-        overflowBehaviorIsVS[xy] || overflowBehaviorIsVH[xy]\n-          ? hasOverflow[xyI] && !overflowBehaviorIsVS[xyI] && !overflowBehaviorIsVH[xyI]\n-          : hasOverflow[xy];\n-      hideOverflow[xy + \'s\'] = hideOverflow[xy] ? overflowBehaviorIsS[xy] || overflowBehaviorIsVS[xy] : false;\n-\n-      canScroll[xy] = hasOverflow[xy] && hideOverflow[xy + \'s\'];\n-    };\n-*/\n-    /*\n-    if (!supportsScrollbarStyling) {\n-      paddingStyle.r -= env._nativeScrollbarSize.y;\n-      paddingStyle.b -= env._nativeScrollbarSize.x;\n-    }\n-    */\n-  });\n-\n-  const onSizeChanged = () => {\n-    _update();\n-  };\n-  const onTrinsicChanged = (heightIntrinsic: CacheValues<boolean>) => {\n-    const { _changed, _value } = heightIntrinsic;\n-    if (_changed) {\n-      style(_content, { height: _value ? \'auto\' : \'100%\' });\n-    }\n-  };\n-\n-  return {\n-    _update,\n-    _onSizeChanged: onSizeChanged,\n-    _onTrinsicChanged: onTrinsicChanged,\n-    _destruct() {\n-      runEach(destructFns);\n-    },\n-  };\n-};\ndiff --git a/packages/overlayscrollbars/src/lifecycles/trinsicLifecycle.ts b/packages/overlayscrollbars/src/lifecycles/trinsicLifecycle.ts\nnew file mode 100644\nindex 0000000..f8be7b8\n--- /dev/null\n+++ b/packages/overlayscrollbars/src/lifecycles/trinsicLifecycle.ts\n@@ -0,0 +1,18 @@\n+import { style } from \'support\';\n+import { LifecycleHub, Lifecycle } from \'lifecycles/lifecycleHub\';\n+\n+export const createTrinsicLifecycle = (lifecycleHub: LifecycleHub): Lifecycle => {\n+  const { _structureSetup } = lifecycleHub;\n+  const { _content } = _structureSetup._targetObj;\n+\n+  return (updateHints) => {\n+    const { _heightIntrinsic } = updateHints;\n+    const { _value: heightIntrinsic, _changed: heightIntrinsicChanged } = _heightIntrinsic;\n+\n+    if (heightIntrinsicChanged) {\n+      style(_content, {\n+        height: heightIntrinsic ? \'auto\' : \'100%\',\n+      });\n+    }\n+  };\n+};\ndiff --git a/packages/overlayscrollbars/tests/browser/lifecycles/structureLifecycle/index.browser.ts b/packages/overlayscrollbars/tests/browser/lifecycles/structureLifecycle/index.browser.ts\nindex 6d670e2..761d423 100644\n--- a/packages/overlayscrollbars/tests/browser/lifecycles/structureLifecycle/index.browser.ts\n+++ b/packages/overlayscrollbars/tests/browser/lifecycles/structureLifecycle/index.browser.ts\n@@ -4,7 +4,7 @@ import { createDiv, appendChildren, parent, style, on, off, addClass, WH, XY, cl\n import { OverlayScrollbars } from \'overlayscrollbars/OverlayScrollbars\';\n \n const targetElm = document.querySelector(\'#target\') as HTMLElement;\n-window.os = OverlayScrollbars({ target: targetElm, padding: null, content: null });\n+window.os = OverlayScrollbars({ target: targetElm, padding: null });\n \n export const resize = (element: HTMLElement) => {\n   const strMouseTouchDownEvent = \'mousedown touchstart\';\n', 'commit_subject': 'trinsic lifecylce', 'repo_name': 'KingSora/OverlayScrollbars', 'committer': {'name': 'Rene', 'email': 'f6a2f098736df63aee0aa8120599a9508d797c8d@hotmail.de', 'time_sec': '1617478992', 'tz_offset': '120', 'date': {'seconds': '1617478992'}}, 'commit_tree': '50e63d9a3b6f2f2ab3bdb99b4a51cffd240c3afe', 'commit_message': 'trinsic lifecylce\n', 'language_name': 'HTML', 'license': 'mit', 'hunks': "@@ -0,0 +1,18 @@\n+import { style } from 'support';\n+import { LifecycleHub, Lifecycle } from 'lifecycles/lifecycleHub';\n+\n+export const createTrinsicLifecycle = (lifecycleHub: LifecycleHub): Lifecycle => {\n+  const { _structureSetup } = lifecycleHub;\n+  const { _content } = _structureSetup._targetObj;\n+\n+  return (updateHints) => {\n+    const { _heightIntrinsic } = updateHints;\n+    const { _value: heightIntrinsic, _changed: heightIntrinsicChanged } = _heightIntrinsic;\n+\n+    if (heightIntrinsicChanged) {\n+      style(_content, {\n+        height: heightIntrinsic ? 'auto' : '100%',\n+      });\n+    }\n+  };\n+};\n", 'addition_count': 18, 'deletion_count': 0, 'src_file': '/dev/null', 'tgt_file': 'b/packages/overlayscrollbars/src/lifecycles/trinsicLifecycle.ts', 'file_extension': '.ts', 'before_file': 'ADDFILE', 'message': 'trinsic lifecylce\n', 'author_name': 'Rene', 'lang': 'ts'}