zhl-methods 1.0.4 → 1.0.5

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/index.css ADDED
@@ -0,0 +1,48 @@
1
+ /* 单行溢出省略号 */
2
+ .nowrap {
3
+ /*溢出部分隐藏*/
4
+ overflow: hidden;
5
+ /*禁止换行*/
6
+ white-space: nowrap;
7
+ /*显示省略号*/
8
+ text-overflow: ellipsis;
9
+ }
10
+ /* 三行溢出省略号 */
11
+ .manyWrap {
12
+ /* 必须结合的属性 ,将对象作为弹性伸缩盒子模型显示 。*/
13
+ display: -webkit-box;
14
+ /* 必须结合的属性 ,设置或检索伸缩盒对象的子元素的排列方式 。*/
15
+ -webkit-box-orient: vertical;
16
+ /*要显示的行数*/
17
+ -webkit-line-clamp: 3;
18
+ line-clamp: 3;
19
+ /* 溢出部分隐藏 */
20
+ overflow: hidden;
21
+ }
22
+ /*滚动条整体部分*/
23
+ .scrollbar ::-webkit-scrollbar {
24
+ width: 8px;
25
+ height: 6px;
26
+ }
27
+ /*滚动条的轨道*/
28
+ .scrollbar ::-webkit-scrollbar-track {
29
+ background-color: #ffffff;
30
+ }
31
+ /*滚动条里面的小方块,能向上向下移动*/
32
+ .scrollbar ::-webkit-scrollbar-thumb {
33
+ background-color: #bfbfbf;
34
+ border-radius: 5px;
35
+ border: 1px solid #f1f1f1;
36
+ box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
37
+ cursor: pointer;
38
+ }
39
+ .scrollbar ::-webkit-scrollbar-thumb:hover {
40
+ background-color: #a8a8a8;
41
+ }
42
+ .scrollbar ::-webkit-scrollbar-thumb:active {
43
+ background-color: #787878;
44
+ }
45
+ /*边角,即两个滚动条的交汇处*/
46
+ .scrollbar ::-webkit-scrollbar-corner {
47
+ background-color: #ffffff;
48
+ }
package/js/index.js CHANGED
@@ -218,3 +218,52 @@ export const downloadFile = (url, name) => {
218
218
  a.click();
219
219
  a.remove();
220
220
  };
221
+ /**
222
+ * 防抖
223
+ * @example debounce(() => {}, 250)
224
+ * @param fn 防抖的函数
225
+ * @param wait 防抖时间 毫秒
226
+ * @returns fn
227
+ */
228
+ export const debounce = (fn, wait = 250) => {
229
+ let timeout = null;
230
+ return function () {
231
+ let context = this;
232
+ let args = arguments;
233
+ if (timeout) clearTimeout(timeout);
234
+ let callNow = !timeout;
235
+ timeout = setTimeout(() => {
236
+ timeout = null;
237
+ }, wait);
238
+ if (callNow) fn.apply(context, args);
239
+ };
240
+ };
241
+ /**
242
+ * 节流
243
+ * @example throttle(()=>{})
244
+ * @param fn 节流的函数
245
+ * @param threshhold 节流时间
246
+ * @param scope this
247
+ * @returns 没有返回值
248
+ */
249
+ export const throttle = (fn, threshhold, scope) => {
250
+ threshhold || (threshhold = 250);
251
+ var last, timer;
252
+ return function () {
253
+ var context = scope || this;
254
+ var now = +new Date(),
255
+ args = arguments;
256
+ if (last && now < last + threshhold) {
257
+ // 如果在节流时间内,则取消之前的延迟调用
258
+ clearTimeout(timer);
259
+ // 设定一个新的延迟调用
260
+ timer = setTimeout(function () {
261
+ last = now;
262
+ fn.apply(context, args);
263
+ }, threshhold);
264
+ } else {
265
+ last = now;
266
+ fn.apply(context, args);
267
+ }
268
+ };
269
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zhl-methods",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "ISC",
package/wx/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ if (!wx) {
2
+ wx = uni;
3
+ }
1
4
  /**
2
5
  * 获取导航栏高度
3
6
  * @returns {number}