pixuireactcomponents 1.3.58 → 1.3.59
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
|
@@ -9,12 +9,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
/**
|
|
13
|
-
* + [已解决]为什么重新创建 CustomScrollBar()时 isDragingSBlock 会被重置为false? 在外部回调中不能使用state
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
12
|
import { h } from 'preact';
|
|
17
|
-
import { useState, useEffect } from 'preact/hooks';
|
|
13
|
+
import { useImperativeHandle, useState, useEffect } from 'preact/hooks';
|
|
18
14
|
var sWindow; // 滚动窗口
|
|
19
15
|
var sBlock; // 滚动条
|
|
20
16
|
var sFrame; // 滚动条外框
|
|
@@ -118,6 +114,18 @@ export function ScrollBar(props) {
|
|
|
118
114
|
sWindow.scrollTop = content_scrollTop;
|
|
119
115
|
}
|
|
120
116
|
};
|
|
117
|
+
useImperativeHandle(props.eventRef, function () { return ({
|
|
118
|
+
scrollTo: scrollTo,
|
|
119
|
+
}); });
|
|
120
|
+
// 重设滚动轴, x预留, y为距离顶部的像素值
|
|
121
|
+
var scrollTo = function (x, y) {
|
|
122
|
+
if (typeof y === 'number') {
|
|
123
|
+
sWindow.scrollTop = y;
|
|
124
|
+
}
|
|
125
|
+
// 停止滚动
|
|
126
|
+
sWindow.style.overflow = 'hidden';
|
|
127
|
+
sWindow.style.overflow = 'scroll';
|
|
128
|
+
};
|
|
121
129
|
return (h("div", { id: "sframe", style: sFrameStyle },
|
|
122
130
|
h("div", { id: "sblock", style: sBlockStyle, draggable: true, onDragStart: function (event) {
|
|
123
131
|
sBlock.style.backgroundImage = "url(".concat(props.sBlockImgClick, ")");
|