cja-phoenix 0.2.5 → 0.2.7

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.
@@ -6,18 +6,12 @@
6
6
  </div>
7
7
  <span class="m-cgg-icon--chevron-down"></span>
8
8
  </div>
9
- <Transition
10
- name="slide"
11
- @before-enter="setHeightZero"
12
- @enter="setHeightSize"
13
- @after-enter="clearHeight"
14
- @leave="setHeightZero"
15
- >
9
+ <Transition name="slide" @enter="slideEnter" @leave="slideLeave">
16
10
  <div
17
11
  v-show="active"
18
12
  ref="contentContainer"
19
13
  class="content-container"
20
- :style="{ height: containerHeight, overflow: containerOverflow }"
14
+ :style="{ height: containerHeight }"
21
15
  >
22
16
  <div ref="contentWrapper" class="content-wrapper">
23
17
  <slot name="content"></slot>
@@ -41,13 +35,18 @@ const active = ref(props.defaultActive);
41
35
  const contentContainer = ref();
42
36
  const contentWrapper = ref();
43
37
  const containerHeight = ref();
44
- const containerOverflow = ref();
45
38
 
46
- const setHeightSize = () => {
39
+ const slideEnter = () => {
40
+ containerHeight.value = "0";
41
+
47
42
  requestAnimationFrame(() => {
48
43
  if (contentContainer.value && contentWrapper.value) {
49
44
  containerHeight.value = `${contentWrapper.value.clientHeight}px`;
50
45
 
46
+ setTimeout(() => {
47
+ containerHeight.value = "";
48
+ }, 200);
49
+
51
50
  if (active.value && props.scrollToContent) {
52
51
  setTimeout(() => {
53
52
  props.scrollToContent?.element.scrollTo({
@@ -61,31 +60,13 @@ const setHeightSize = () => {
61
60
  });
62
61
  };
63
62
 
64
- const setHeightZero = () => {
63
+ const slideLeave = () => {
65
64
  containerHeight.value = `${contentWrapper.value.clientHeight}px`;
66
65
 
67
66
  requestAnimationFrame(() => {
68
67
  containerHeight.value = "0";
69
- containerOverflow.value = "";
70
68
  });
71
69
  };
72
-
73
- const clearHeight = () => {
74
- containerHeight.value = "";
75
- containerOverflow.value = "visible";
76
- };
77
-
78
- onMounted(() => {
79
- if (props.defaultActive) {
80
- setHeightSize();
81
- }
82
-
83
- window.addEventListener("resize", setHeightSize);
84
- });
85
-
86
- onUnmounted(() => {
87
- window.removeEventListener("resize", setHeightSize);
88
- });
89
70
  </script>
90
71
 
91
72
  <style lang="scss" scoped>
@@ -104,9 +85,12 @@ onUnmounted(() => {
104
85
  }
105
86
 
106
87
  .content-container {
107
- box-sizing: border-box;
108
- overflow: hidden;
109
88
  transition: all 0.2s linear;
89
+
90
+ &.slide-leave-active,
91
+ &.slide-enter-active {
92
+ overflow: hidden;
93
+ }
110
94
  }
111
95
 
112
96
  &.active {
@@ -114,5 +98,11 @@ onUnmounted(() => {
114
98
  transform: rotate(180deg);
115
99
  }
116
100
  }
101
+
102
+ &:not(.active) {
103
+ .content-container {
104
+ overflow: hidden;
105
+ }
106
+ }
117
107
  }
118
108
  </style>
@@ -7,7 +7,7 @@
7
7
  <div
8
8
  class="fixed-wrapper"
9
9
  :class="{ 'position-fixed': positionFixed }"
10
- :style="{ ...size, ...position }"
10
+ :style="{ ...size, ...position, maxWidth: fixedWrapperWidth }"
11
11
  ref="fixedWrapper"
12
12
  >
13
13
  <slot></slot>
@@ -16,11 +16,12 @@
16
16
  </template>
17
17
 
18
18
  <script lang="ts" setup>
19
- import { onUnmounted, onMounted } from "vue";
19
+ import { onUnmounted, onMounted, watch } from "vue";
20
20
  import { ref } from "vue";
21
21
 
22
22
  const props = withDefaults(
23
23
  defineProps<{
24
+ active?: boolean;
24
25
  scrollThreshold?: number;
25
26
  fixWidth?: boolean;
26
27
  size?: {
@@ -35,6 +36,7 @@ const props = withDefaults(
35
36
  };
36
37
  }>(),
37
38
  {
39
+ active: true,
38
40
  scrollThreshold: 0,
39
41
  fixWidth: true,
40
42
  }
@@ -44,29 +46,43 @@ const positionFixed = ref(false);
44
46
  const fixedContainer = ref();
45
47
  const fixedContainerHeight = ref("");
46
48
  const fixedWrapper = ref();
49
+ const fixedWrapperWidth = ref("");
47
50
 
48
51
  const fixPosition = () => {
49
- if (fixedContainer.value) {
52
+ if (fixedContainer.value && props.active) {
50
53
  positionFixed.value =
51
54
  window.scrollY > fixedContainer.value.offsetTop + props.scrollThreshold;
52
55
 
53
56
  fixedContainerHeight.value = positionFixed.value
54
57
  ? `${fixedWrapper.value.clientHeight}px`
55
58
  : "";
59
+ } else {
60
+ positionFixed.value = false;
61
+ fixedContainerHeight.value = "";
56
62
  }
57
63
  };
58
64
 
59
65
  const setWidth = () => {
60
- fixedWrapper.value.style.maxWidth = `${fixedContainer.value.offsetWidth}px`;
66
+ fixedWrapperWidth.value = props.active
67
+ ? `${fixedContainer.value.offsetWidth}px`
68
+ : "";
61
69
  };
62
70
 
71
+ watch(
72
+ () => props.active,
73
+ () => {
74
+ if (props.fixWidth) {
75
+ setWidth();
76
+ }
77
+ }
78
+ );
79
+
63
80
  onMounted(() => {
64
81
  window.addEventListener("scroll", fixPosition);
65
82
  fixPosition();
66
83
 
67
84
  if (props.fixWidth) {
68
85
  window.addEventListener("resize", setWidth);
69
- setWidth();
70
86
  }
71
87
  });
72
88
 
@@ -0,0 +1,20 @@
1
+ export const JsonReviver = (data: any) =>
2
+ JSON.parse(data, (k, v) => {
3
+ if (v === "true" || v === "false") {
4
+ return v === "true";
5
+ }
6
+
7
+ if (Number(v) || v === "0") {
8
+ return Number(v);
9
+ }
10
+
11
+ if (v === "undefined") {
12
+ return undefined;
13
+ }
14
+
15
+ if (v === "null") {
16
+ return null;
17
+ }
18
+
19
+ return v;
20
+ });
@@ -1,4 +1,5 @@
1
1
  import { generateRoutes } from "./RouteGenerator";
2
2
  import { useViewportDetector } from "./ViewportDetector";
3
+ import { JsonReviver } from "./JsonReviver";
3
4
 
4
- export { generateRoutes, useViewportDetector };
5
+ export { generateRoutes, useViewportDetector, JsonReviver };