@varlet/ui 2.5.3 → 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.
- package/es/back-top/BackTop.js +3 -23
- package/es/pull-refresh/PullRefresh.js +2 -2
- package/es/pull-refresh/props.js +3 -0
- package/es/utils/elements.js +15 -1
- package/es/varlet.esm.js +1269 -1268
- package/highlight/attributes.json +4 -0
- package/highlight/tags.json +1 -0
- package/highlight/web-types.json +10 -1
- package/lib/back-top/BackTop.js +1 -21
- package/lib/pull-refresh/PullRefresh.js +1 -1
- package/lib/pull-refresh/props.js +3 -0
- package/lib/utils/elements.js +16 -0
- package/package.json +7 -7
- package/types/pullRefresh.d.ts +1 -0
- package/umd/varlet.js +6 -6
package/es/back-top/BackTop.js
CHANGED
|
@@ -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 {
|
|
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
|
});
|
|
@@ -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 {
|
package/es/pull-refresh/props.js
CHANGED
package/es/utils/elements.js
CHANGED
|
@@ -2,7 +2,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
2
2
|
|
|
3
3
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
4
4
|
|
|
5
|
-
import { isNumber, isString, kebabCase, toNumber } from '@varlet/shared';
|
|
5
|
+
import { isNumber, isObject, isString, kebabCase, toNumber } from '@varlet/shared';
|
|
6
6
|
import { getGlobalThis } from './shared';
|
|
7
7
|
export function getLeft(element) {
|
|
8
8
|
var {
|
|
@@ -92,6 +92,20 @@ export function getAllParentScroller(el) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
return allParentScroller;
|
|
95
|
+
}
|
|
96
|
+
export function getTarget(target, componentName) {
|
|
97
|
+
if (isString(target)) {
|
|
98
|
+
var el = document.querySelector(target);
|
|
99
|
+
|
|
100
|
+
if (!el) {
|
|
101
|
+
throw Error("[Varlet] " + componentName + ": target element cannot found");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return el;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (isObject(target)) return target;
|
|
108
|
+
throw Error("[Varlet] " + componentName + ": type of prop \"target\" should be a selector or an element object");
|
|
95
109
|
} // example 1rem
|
|
96
110
|
|
|
97
111
|
export var isRem = value => isString(value) && value.endsWith('rem'); // e.g. 1 || 1px
|