@varlet/cli 2.2.1 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varlet/cli",
3
- "version": "2.2.1",
3
+ "version": "2.3.1",
4
4
  "type": "module",
5
5
  "description": "cli of varlet",
6
6
  "bin": {
@@ -40,8 +40,6 @@
40
40
  "@babel/preset-env": "^7.14.8",
41
41
  "@babel/preset-typescript": "^7.14.5",
42
42
  "@types/inquirer": "^9.0.2",
43
- "@varlet/markdown-vite-plugin": "2.2.1",
44
- "@varlet/shared": "2.2.1",
45
43
  "@vitejs/plugin-vue": "3.0.1",
46
44
  "@vitejs/plugin-vue-jsx": "2.0.0",
47
45
  "@vue/babel-plugin-jsx": "1.1.1",
@@ -69,7 +67,9 @@
69
67
  "vite": "3.0.4",
70
68
  "vite-plugin-html": "^2.1.0",
71
69
  "vue": "3.2.25",
72
- "vue-jest": "^5.0.0-alpha.8"
70
+ "vue-jest": "^5.0.0-alpha.8",
71
+ "@varlet/markdown-vite-plugin": "2.3.1",
72
+ "@varlet/shared": "2.3.1"
73
73
  },
74
74
  "devDependencies": {
75
75
  "@types/babel__core": "^7.1.12",
@@ -80,19 +80,19 @@
80
80
  "@types/lodash-es": "^4.17.5",
81
81
  "@types/node": "^18.7.20",
82
82
  "@types/semver": "^7.3.9",
83
- "@varlet/icons": "2.2.1",
84
- "@varlet/touch-emulator": "2.2.1"
83
+ "@varlet/touch-emulator": "2.3.1",
84
+ "@varlet/icons": "2.3.1"
85
85
  },
86
86
  "peerDependencies": {
87
- "@varlet/icons": "2.2.1",
88
- "@varlet/touch-emulator": "2.2.1",
89
87
  "@vue/runtime-core": "3.2.16",
90
88
  "@vue/test-utils": "^2.0.2",
91
89
  "clipboard": "^2.0.6",
92
90
  "live-server": "^1.2.1",
93
91
  "lodash-es": "^4.17.21",
94
92
  "vue": "3.2.25",
95
- "vue-router": "4.0.12"
93
+ "vue-router": "4.0.12",
94
+ "@varlet/touch-emulator": "2.3.1",
95
+ "@varlet/icons": "2.3.1"
96
96
  },
97
97
  "scripts": {
98
98
  "dev": "tsc --watch",
@@ -6,16 +6,45 @@ export default defineComponent({
6
6
  name: 'AnimationBox',
7
7
  setup() {
8
8
  const varletLogoAnimationRef = ref<HTMLElement>()
9
+ const domObserve = new MutationObserver(_onDomChanged)
9
10
  animationBoxData.attrs = useAttrs()
10
11
 
11
12
  onMounted(() => {
12
13
  animationEl.value = varletLogoAnimationRef.value
13
- animationElClientRect.value = varletLogoAnimationRef?.value?.getBoundingClientRect();
14
+ varletLogoAnimationRef.value && domObserve.observe(varletLogoAnimationRef.value, { childList: true })
15
+
14
16
 
15
17
  isMountedCount.value <= 2 && (isMountedCount.value += 1)
16
18
  })
17
19
 
20
+ function _onDomChanged(mutations: MutationRecord[]) {
21
+ if (!mutations.length || !varletLogoAnimationRef.value) return;
22
+ const normal = animationEl.value?.getBoundingClientRect()
23
+ const hasFloat: boolean = _onGetNodePosition(varletLogoAnimationRef.value);
24
+
25
+ animationElClientRect.value = hasFloat ? normal : {
26
+ top: (animationEl.value?.getBoundingClientRect().top || 0) + window.scrollY,
27
+ left: (animationEl.value?.getBoundingClientRect().left || 0),
28
+ width: animationEl.value?.getBoundingClientRect().width || 0,
29
+ height: animationEl.value?.getBoundingClientRect().height || 0,
30
+ }
31
+ }
32
+
33
+ function _onGetNodePosition(node: Element, stopNode = document.body): boolean {
34
+ const css = window.getComputedStyle(node, null);
35
+ if (css.position === 'fixed') {
36
+ return true
37
+ }
38
+ if (node === stopNode) {
39
+ return false
40
+ }
41
+
42
+ return _onGetNodePosition(node.parentElement || document.body)
43
+ }
44
+
18
45
  onUnmounted(() => {
46
+ domObserve.disconnect()
47
+ varletLogoAnimationRef.value = undefined
19
48
  animationEl.value = undefined
20
49
  animationElClientRect.value = undefined
21
50
  })
@@ -28,6 +57,6 @@ export default defineComponent({
28
57
  </script>
29
58
 
30
59
  <template>
31
- <div ref="varletLogoAnimationRef" data-animation="port"></div>
60
+ <div ref="varletLogoAnimationRef"></div>
32
61
  </template>
33
62
 
@@ -3,13 +3,15 @@ import config from '@config'
3
3
  import { get } from 'lodash-es'
4
4
  import { computed, defineComponent, onMounted, onBeforeUnmount, ref, watch, nextTick } from 'vue'
5
5
  import { animationBoxData, animationEl, animationElClientRect, isMountedCount } from '../floating'
6
+
6
7
  import type { Ref, StyleValue } from 'vue'
8
+ import type { Rect } from '../floating'
7
9
 
8
10
  export default defineComponent({
9
11
  name: 'LogoAnimation',
10
12
  setup() {
11
13
  const logo: Ref<string> = get(config, 'logo')
12
- const proxyRect: Ref<DOMRect | undefined> = ref<DOMRect>()
14
+ const proxyRect: Ref<Rect | undefined> = ref<Rect>()
13
15
  const floatingState: Ref<boolean> = ref<boolean>(false)
14
16
 
15
17
  watch(animationElClientRect, async (newClientRect) => {
@@ -1,9 +1,11 @@
1
1
  import { reactive, ref } from 'vue'
2
2
 
3
+ export type Rect = Pick<DOMRect, 'width' | 'height' | 'top' | 'left'>
4
+
3
5
  export const animationBoxData = reactive<any>({})
4
6
 
5
7
  export const animationEl = ref<HTMLElement | null>()
6
8
 
7
- export const animationElClientRect = ref<DOMRect | null>()
9
+ export const animationElClientRect = ref<Rect | null>()
8
10
 
9
11
  export const isMountedCount = ref<number>(0)