Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ChenYFan_OHHH
uni-app
提交
aa4c6b69
U
uni-app
项目概览
ChenYFan_OHHH
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aa4c6b69
编写于
7月 21, 2021
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(App): swiper use rebuild
上级
1a9fc7a6
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
48 addition
and
9 deletion
+48
-9
packages/uni-app-plus/dist/uni-app-view.umd.js
packages/uni-app-plus/dist/uni-app-view.umd.js
+19
-2
packages/uni-components/src/components/swiper/index.tsx
packages/uni-components/src/components/swiper/index.tsx
+13
-3
packages/uni-components/src/helpers/useRebuild.ts
packages/uni-components/src/helpers/useRebuild.ts
+6
-0
packages/uni-h5/dist/uni-h5.cjs.js
packages/uni-h5/dist/uni-h5.cjs.js
+5
-2
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+5
-2
未找到文件。
packages/uni-app-plus/dist/uni-app-view.umd.js
浏览文件 @
aa4c6b69
...
@@ -13170,6 +13170,10 @@ var __publicField = (obj, key, value) => {
...
@@ -13170,6 +13170,10 @@ var __publicField = (obj, key, value) => {
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
}
}
};
};
function useRebuild(callback) {
const instance = getCurrentInstance();
instance.rebuild = callback;
}
const props$5 = {
const props$5 = {
indicatorDots: {
indicatorDots: {
type: [Boolean, String],
type: [Boolean, String],
...
@@ -13692,14 +13696,23 @@ var __publicField = (obj, key, value) => {
...
@@ -13692,14 +13696,23 @@ var __publicField = (obj, key, value) => {
function updateSwiperContexts() {
function updateSwiperContexts() {
const contexts = [];
const contexts = [];
for (let index2 = 0; index2 < swiperItems.length; index2++) {
for (let index2 = 0; index2 < swiperItems.length; index2++) {
const swiperItem2 = swiperItems[index2];
let swiperItem2 = swiperItems[index2];
const swiperContext = originSwiperContexts.find((context) => swiperItem2.el === context.rootRef.value);
if (!(swiperItem2 instanceof Element)) {
swiperItem2 = swiperItem2.el;
}
const swiperContext = originSwiperContexts.find((context) => swiperItem2 === context.rootRef.value);
if (swiperContext) {
if (swiperContext) {
contexts.push(markRaw(swiperContext));
contexts.push(markRaw(swiperContext));
}
}
}
}
swiperContexts.value = contexts;
swiperContexts.value = contexts;
}
}
{
useRebuild(() => {
swiperItems = slideFrameRef.value.children;
updateSwiperContexts();
});
}
const addSwiperContext = function(swiperContext) {
const addSwiperContext = function(swiperContext) {
originSwiperContexts.push(swiperContext);
originSwiperContexts.push(swiperContext);
updateSwiperContexts();
updateSwiperContexts();
...
@@ -14391,6 +14404,10 @@ var __publicField = (obj, key, value) => {
...
@@ -14391,6 +14404,10 @@ var __publicField = (obj, key, value) => {
{
{
console.log(formatLog("Observer", mutations));
console.log(formatLog("Observer", mutations));
}
}
const vm = this.$.__vueParentComponent;
if (vm.rebuild) {
vm.rebuild();
}
});
});
observer.observe(elem, {
observer.observe(elem, {
childList: true,
childList: true,
...
...
packages/uni-components/src/components/swiper/index.tsx
浏览文件 @
aa4c6b69
...
@@ -16,6 +16,7 @@ import { defineBuiltInComponent } from '../../helpers/component'
...
@@ -16,6 +16,7 @@ import { defineBuiltInComponent } from '../../helpers/component'
import
{
useCustomEvent
,
CustomEventTrigger
}
from
'
../../helpers/useEvent
'
import
{
useCustomEvent
,
CustomEventTrigger
}
from
'
../../helpers/useEvent
'
import
{
useTouchtrack
}
from
'
../../helpers/useTouchtrack
'
import
{
useTouchtrack
}
from
'
../../helpers/useTouchtrack
'
import
{
flatVNode
}
from
'
../../helpers/flatVNode
'
import
{
flatVNode
}
from
'
../../helpers/flatVNode
'
import
{
useRebuild
}
from
'
../../helpers/useRebuild
'
import
{
rpx2px
}
from
'
@dcloudio/uni-core
'
import
{
rpx2px
}
from
'
@dcloudio/uni-core
'
const
props
=
{
const
props
=
{
...
@@ -643,15 +644,18 @@ export default /*#__PURE__*/ defineBuiltInComponent({
...
@@ -643,15 +644,18 @@ export default /*#__PURE__*/ defineBuiltInComponent({
height
:
!
props
.
vertical
?
'
100%
'
:
value
,
height
:
!
props
.
vertical
?
'
100%
'
:
value
,
}
}
})
})
let
swiperItems
:
VNode
[]
=
[]
let
swiperItems
:
VNode
[]
|
HTMLCollection
=
[]
const
originSwiperContexts
:
SwiperContext
[]
=
[]
const
originSwiperContexts
:
SwiperContext
[]
=
[]
const
swiperContexts
:
Ref
<
SwiperContext
[]
>
=
ref
([])
const
swiperContexts
:
Ref
<
SwiperContext
[]
>
=
ref
([])
function
updateSwiperContexts
()
{
function
updateSwiperContexts
()
{
const
contexts
:
SwiperContext
[]
=
[]
const
contexts
:
SwiperContext
[]
=
[]
for
(
let
index
=
0
;
index
<
swiperItems
.
length
;
index
++
)
{
for
(
let
index
=
0
;
index
<
swiperItems
.
length
;
index
++
)
{
const
swiperItem
=
swiperItems
[
index
]
let
swiperItem
:
VNode
|
Element
=
swiperItems
[
index
]
if
(
!
(
swiperItem
instanceof
Element
))
{
swiperItem
=
swiperItem
.
el
as
HTMLElement
}
const
swiperContext
=
originSwiperContexts
.
find
(
const
swiperContext
=
originSwiperContexts
.
find
(
(
context
)
=>
swiperItem
.
el
===
context
.
rootRef
.
value
(
context
)
=>
swiperItem
===
context
.
rootRef
.
value
)
)
if
(
swiperContext
)
{
if
(
swiperContext
)
{
contexts
.
push
(
markRaw
(
swiperContext
))
contexts
.
push
(
markRaw
(
swiperContext
))
...
@@ -659,6 +663,12 @@ export default /*#__PURE__*/ defineBuiltInComponent({
...
@@ -659,6 +663,12 @@ export default /*#__PURE__*/ defineBuiltInComponent({
}
}
swiperContexts
.
value
=
contexts
swiperContexts
.
value
=
contexts
}
}
if
(
__PLATFORM__
===
'
app
'
)
{
useRebuild
(()
=>
{
swiperItems
=
(
slideFrameRef
.
value
as
HTMLElement
).
children
updateSwiperContexts
()
})
}
const
addSwiperContext
:
AddSwiperContext
=
function
(
swiperContext
)
{
const
addSwiperContext
:
AddSwiperContext
=
function
(
swiperContext
)
{
originSwiperContexts
.
push
(
swiperContext
)
originSwiperContexts
.
push
(
swiperContext
)
updateSwiperContexts
()
updateSwiperContexts
()
...
...
packages/uni-components/src/helpers/useRebuild.ts
0 → 100644
浏览文件 @
aa4c6b69
import
{
getCurrentInstance
}
from
'
vue
'
export
function
useRebuild
(
callback
:
()
=>
void
)
{
const
instance
=
getCurrentInstance
()
as
any
instance
.
rebuild
=
callback
}
packages/uni-h5/dist/uni-h5.cjs.js
浏览文件 @
aa4c6b69
...
@@ -6120,8 +6120,11 @@ var index$g = /* @__PURE__ */ defineBuiltInComponent({
...
@@ -6120,8 +6120,11 @@ var index$g = /* @__PURE__ */ defineBuiltInComponent({
function
updateSwiperContexts
()
{
function
updateSwiperContexts
()
{
const
contexts
=
[];
const
contexts
=
[];
for
(
let
index2
=
0
;
index2
<
swiperItems
.
length
;
index2
++
)
{
for
(
let
index2
=
0
;
index2
<
swiperItems
.
length
;
index2
++
)
{
const
swiperItem
=
swiperItems
[
index2
];
let
swiperItem
=
swiperItems
[
index2
];
const
swiperContext
=
originSwiperContexts
.
find
((
context
)
=>
swiperItem
.
el
===
context
.
rootRef
.
value
);
if
(
!
(
swiperItem
instanceof
Element
))
{
swiperItem
=
swiperItem
.
el
;
}
const
swiperContext
=
originSwiperContexts
.
find
((
context
)
=>
swiperItem
===
context
.
rootRef
.
value
);
if
(
swiperContext
)
{
if
(
swiperContext
)
{
contexts
.
push
(
vue
.
markRaw
(
swiperContext
));
contexts
.
push
(
vue
.
markRaw
(
swiperContext
));
}
}
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
aa4c6b69
...
@@ -12544,8 +12544,11 @@ var Swiper = /* @__PURE__ */ defineBuiltInComponent({
...
@@ -12544,8 +12544,11 @@ var Swiper = /* @__PURE__ */ defineBuiltInComponent({
function updateSwiperContexts() {
function updateSwiperContexts() {
const contexts = [];
const contexts = [];
for (let index2 = 0; index2 < swiperItems.length; index2++) {
for (let index2 = 0; index2 < swiperItems.length; index2++) {
const swiperItem = swiperItems[index2];
let swiperItem = swiperItems[index2];
const swiperContext = originSwiperContexts.find((context) => swiperItem.el === context.rootRef.value);
if (!(swiperItem instanceof Element)) {
swiperItem = swiperItem.el;
}
const swiperContext = originSwiperContexts.find((context) => swiperItem === context.rootRef.value);
if (swiperContext) {
if (swiperContext) {
contexts.push(markRaw(swiperContext));
contexts.push(markRaw(swiperContext));
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录