@varlet/ui 2.5.2 → 2.5.4

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.
@@ -2,9 +2,9 @@ import { defineComponent, ref, onMounted, onBeforeUnmount } from 'vue';
2
2
  import VarButton from '../button';
3
3
  import VarIcon from '../icon';
4
4
  import { props } from './props';
5
- import { isString, throttle, isObject } from '@varlet/shared';
5
+ import { throttle } from '@varlet/shared';
6
6
  import { easeInOutCubic } from '../utils/shared';
7
- import { getScrollTop, getScrollLeft, scrollTo, getParentScroller, toPxNum, toSizeUnit } from '../utils/elements';
7
+ import { getScrollTop, getScrollLeft, scrollTo, getParentScroller, toPxNum, toSizeUnit, getTarget } from '../utils/elements';
8
8
  import { call, createNamespace } from '../utils/components';
9
9
  var {
10
10
  n,
@@ -78,28 +78,8 @@ export default defineComponent({
78
78
  };
79
79
 
80
80
  var throttleScroll = throttle(scroll, 200);
81
-
82
- var getTarget = () => {
83
- var {
84
- target
85
- } = props;
86
-
87
- if (isString(target)) {
88
- var el = document.querySelector(props.target);
89
-
90
- if (!el) {
91
- throw Error('[Varlet] BackTop: target element cannot found');
92
- }
93
-
94
- return el;
95
- }
96
-
97
- if (isObject(target)) return target;
98
- throw Error('[Varlet] BackTop: type of prop "target" should be a selector or an element object');
99
- };
100
-
101
81
  onMounted(() => {
102
- target = props.target ? getTarget() : getParentScroller(backTopEl.value);
82
+ target = props.target ? getTarget(props.target, 'BackTop') : getParentScroller(backTopEl.value);
103
83
  target.addEventListener('scroll', throttleScroll);
104
84
  disabled.value = false;
105
85
  });
package/es/menu/menu.css CHANGED
@@ -1 +1 @@
1
- :root { --menu-background-color: #fff;}.var-menu-enter-from,.var-menu-leave-to { opacity: 0;}.var-menu-enter-active,.var-menu-leave-active { transition-property: opacity; transition-duration: 0.25s;}.var-menu { display: inline-block;}.var-menu__menu { overflow: auto;}.var-menu--menu-background-color { background: var(--menu-background-color); transition: opacity 0.25s, background-color 0.25s;}
1
+ :root { --menu-background-color: #fff;}.var-menu-enter-from,.var-menu-leave-to { opacity: 0;}.var-menu-enter-active,.var-menu-leave-active { transition-property: opacity; transition-duration: 0.25s;}.var-menu { display: inline-block;}.var-menu--menu-background-color { background: var(--menu-background-color); transition: opacity 0.25s, background-color 0.25s;}
@@ -4,7 +4,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
4
4
 
5
5
  import VarIcon from '../icon';
6
6
  import { defineComponent, ref, computed, watch, onMounted } from 'vue';
7
- import { getParentScroller, getScrollTop } from '../utils/elements';
7
+ import { getParentScroller, getScrollTop, getTarget } from '../utils/elements';
8
8
  import { props } from './props';
9
9
  import { toNumber } from '@varlet/shared';
10
10
  import { call, createNamespace } from '../utils/components';
@@ -165,7 +165,7 @@ export default defineComponent({
165
165
  }
166
166
  });
167
167
  onMounted(() => {
168
- scroller = getParentScroller(freshNode.value);
168
+ scroller = props.target ? getTarget(props.target, 'PullRefresh') : getParentScroller(freshNode.value);
169
169
  setPosition();
170
170
  });
171
171
  return {
@@ -34,6 +34,9 @@ export var props = {
34
34
  successColor: {
35
35
  type: String
36
36
  },
37
+ target: {
38
+ type: [String, Object]
39
+ },
37
40
  onRefresh: defineListenerProp(),
38
41
  'onUpdate:modelValue': defineListenerProp()
39
42
  };