@soei/flyweight 0.0.2 → 0.0.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/LICENSE +7 -0
- package/README.md +36 -0
- package/dist/Flyweight.cjs +1 -1
- package/dist/Flyweight.js +40 -26
- package/dist/style.css +1 -1
- package/package.json +11 -9
- package/src/Flyweight.vue +81 -27
- package/dist/vite.svg +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
The ISC License (ISC)
|
|
2
|
+
|
|
3
|
+
Copyright 2016-present soei(alwbg@163.com)
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
1
|
# 享元模式
|
|
2
2
|
|
|
3
|
+
```html
|
|
4
|
+
<div style="height:100px;width:300px;">
|
|
5
|
+
<!-- 确认父容器 宽 高 存在, 依赖父容器 `宽`, `高` 计算 -->
|
|
6
|
+
<s-flyweight ...></s-flyweight>
|
|
7
|
+
</div>
|
|
8
|
+
```
|
|
9
|
+
|
|
3
10
|
### 更新日志
|
|
4
11
|
|
|
12
|
+
### `0.0.4`
|
|
13
|
+
|
|
14
|
+
- #### 扩展 `width` 赋值
|
|
15
|
+
```html
|
|
16
|
+
<!-- 添加`百分比`计算, 计算顺序, 左 => 右 -->
|
|
17
|
+
<s-flyweight width="100% / 2 - 10px"></s-flyweight>
|
|
18
|
+
<s-flyweight width="calc(100% - 100px)"></s-flyweight>
|
|
19
|
+
<s-flyweight width="100% - 100px"></s-flyweight>
|
|
20
|
+
<s-flyweight width="100px - 10px"></s-flyweight>
|
|
21
|
+
<s-flyweight width="100px"></s-flyweight>
|
|
22
|
+
```
|
|
23
|
+
- #### 优化了 slot `end` 的呈现逻辑
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<!-- onend为滑动到底时, 回调函数 -->
|
|
27
|
+
<s-flyweight :flys="..." @onend="...">
|
|
28
|
+
<template #default="{ data, index }"> 呈现内容 {{data.*}} </template>
|
|
29
|
+
<template #end> ...显示在最下面的相关信息 </template>
|
|
30
|
+
</s-flyweight>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### `0.0.3`
|
|
34
|
+
|
|
35
|
+
- #### 新增 `:top`
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<s-flyweight :top="滚动高度"></s-flyweight>
|
|
39
|
+
```
|
|
40
|
+
|
|
5
41
|
### `0.0.2`
|
|
6
42
|
|
|
7
43
|
- #### 优化了 `Vue3` 的 `兼容` 问题
|
package/dist/Flyweight.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@soei/util"),h=require("vue");const p=(e,t)=>{const i=e.__vccOpts||e;for(const[r,l]of t)i[r]=l;return i};let m=e=>e==null||e==null,x=(...e)=>{console.info("::::FLYWEIGHT",...e)};const k={name:"Flyweight",props:{flys:{type:Array,default:()=>[]},width:{type:Number,default:0},height:{type:Number,default:100},offset:{type:Array,default:()=>[0,0]},lazy:{type:Number,default:100},view:{type:Object,default:()=>null},index:{type:Number,default:0},top:{type:Number,default:!1},left:{type:Number,default:!1}},computed:{flyweight(){return this.$refs.flyweight}},data(){return{flyweights:[],actice:!1,Height:null,column:1,row:1,fwheight:10,count:0,task:[]}},watch:{flys(e){this.count=e.length,this.re();let t=this.task.shift();t&&this.$nextTick(()=>{this.setview(t)})},view:{handler(e){this.setview(e)},immediate:!0},index(e){this.setindex(e)},top(e){this.flyweight.scrollTop=e},left(e){this.flyweight.scrollLeft=e}},mounted(){this.flyweights=[],this.$set||(this.$set=(e,t,i)=>{e[t]=i}),this.setindex(this.index);try{new ResizeObserver(()=>{this.re(),this.$emit("resize")}).observe(this.flyweight)}catch(e){x(e)}},methods:{cheackflys(e){if(!this.flys.length)return e&&this.task.push(e),!0},setview(e){c.runer([this.cheackflys,t=>{t=t||{};let i=t.index||c.each(this.flys,(r,l,n,s)=>{if(l[n]==s)return r},t.picker,t.id);m(i)||this.setindex(i)}],this,e)},setindex(e){c.runer([this.cheackflys,({index:t})=>{this.$nextTick(()=>{let i=t/this.column>>0,r=this.fwheight;(this.flyweight.scrollTop/r>>0)+this.row-i-1>0||(this.flyweight.scrollTop=i*r,this.scroll())})}],this,{index:e})},lazyrun(e,t){clearTimeout(this.time),this.time=setTimeout(()=>{c.runer(e)},t||this.lazy)},run(e){let t=c.picker(e.target,"scrollTop=>top");c.each(this.flyweights,(i,r,l,n,s,o,u,y)=>{if(l=i/s>>0,u=l+n*(+(l<o%n)+(o/n>>0)),y=u*s+i%s,y>=this.count){this.lazyrun(()=>this.$emit("onend",!0));return}r.index=u,r.top=r.index*this.fwheight,r.data=this.flys[y]},null,this.row,this.column,t.top/this.fwheight>>0)},scroll(e){this.run(e||{target:this.flyweight})},re(){let e=this.flyweight,t=c.picker(e,"clientHeight=>height,clientWidth=>width");this.$nextTick(()=>{let[i,r]=this.offset,l=this.width;l==0&&(l=t.width);let n=l+i,s=this.height+r,o=t.width/n>>0,u=t.height/s>>0;this.row=u+2,this.column=o,this.fwheight=s;let y=t.width%n/(o-1)>>0;this.Height=Math.ceil(this.count/o)*s;let d=Math.min(this.count,o*this.row),a=d-1,f,g;for(;d-- >0;)f=a-d,g=this.flys[f],e=this.flyweights[f],this.$set(this.flyweights,f,{data:g,top:(f/o>>0)*s,left:f%o*(n+y),index:f/o>>0});this.flyweights.length=a+1,this.scroll()})}}};function _(e,t,i,r,l,n){return h.openBlock(),h.createElementBlock("div",{ref:"flyweight",class:h.normalizeClass(["flyweight",{"flyweight-active":l.actice}]),style:h.normalizeStyle({"--width":i.width?i.width+"px":"100%","--height":i.height+"px"}),onScroll:t[0]||(t[0]=(...s)=>n.scroll&&n.scroll(...s))},[h.createElementVNode("div",{class:"flyweight-all",style:h.normalizeStyle({"--flyweight-height":l.Height+"px"})},[(h.openBlock(!0),h.createElementBlock(h.Fragment,null,h.renderList(l.flyweights,(s,o)=>(h.openBlock(),h.createElementBlock("div",{key:o,style:h.normalizeStyle({top:s.top+"px",left:s.left+"px"})},[h.renderSlot(e.$slots,"default",{data:s.data,index:s.index},void 0,!0)],4))),128))],4),l.flyweights.length?h.renderSlot(e.$slots,"end",{key:0},void 0,!0):h.createCommentVNode("",!0)],38)}const w=p(k,[["render",_],["__scopeId","data-v-075d9b23"]]),v=[w],b={install(e){v.forEach(t=>{e.component("s-"+t.name.toLowerCase(),t)})}};exports.Flyweight=w;exports.default=b;
|
package/dist/Flyweight.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { runer as
|
|
2
|
-
import { openBlock as
|
|
1
|
+
import { runer as y, each as m, picker as x } from "@soei/util";
|
|
2
|
+
import { openBlock as d, createElementBlock as g, normalizeClass as k, normalizeStyle as w, createElementVNode as v, Fragment as b, renderList as z, renderSlot as _, createCommentVNode as T } from "vue";
|
|
3
3
|
const N = (t, e) => {
|
|
4
4
|
const i = t.__vccOpts || t;
|
|
5
5
|
for (const [l, s] of e)
|
|
@@ -39,6 +39,14 @@ const H = {
|
|
|
39
39
|
index: {
|
|
40
40
|
type: Number,
|
|
41
41
|
default: 0
|
|
42
|
+
},
|
|
43
|
+
top: {
|
|
44
|
+
type: Number,
|
|
45
|
+
default: !1
|
|
46
|
+
},
|
|
47
|
+
left: {
|
|
48
|
+
type: Number,
|
|
49
|
+
default: !1
|
|
42
50
|
}
|
|
43
51
|
},
|
|
44
52
|
computed: {
|
|
@@ -74,6 +82,12 @@ const H = {
|
|
|
74
82
|
},
|
|
75
83
|
index(t) {
|
|
76
84
|
this.setindex(t);
|
|
85
|
+
},
|
|
86
|
+
top(t) {
|
|
87
|
+
this.flyweight.scrollTop = t;
|
|
88
|
+
},
|
|
89
|
+
left(t) {
|
|
90
|
+
this.flyweight.scrollLeft = t;
|
|
77
91
|
}
|
|
78
92
|
},
|
|
79
93
|
mounted() {
|
|
@@ -94,17 +108,17 @@ const H = {
|
|
|
94
108
|
return t && this.task.push(t), !0;
|
|
95
109
|
},
|
|
96
110
|
setview(t) {
|
|
97
|
-
|
|
111
|
+
y([this.cheackflys, (e) => {
|
|
98
112
|
e = e || {};
|
|
99
|
-
let i = e.index || m(this.flys, (l, s,
|
|
100
|
-
if (s[
|
|
113
|
+
let i = e.index || m(this.flys, (l, s, r, h) => {
|
|
114
|
+
if (s[r] == h)
|
|
101
115
|
return l;
|
|
102
116
|
}, e.picker, e.id);
|
|
103
117
|
$(i) || this.setindex(i);
|
|
104
118
|
}], this, t);
|
|
105
119
|
},
|
|
106
120
|
setindex(t) {
|
|
107
|
-
|
|
121
|
+
y([this.cheackflys, ({ index: e }) => {
|
|
108
122
|
this.$nextTick(() => {
|
|
109
123
|
let i = e / this.column >> 0, l = this.fwheight;
|
|
110
124
|
(this.flyweight.scrollTop / l >> 0) + this.row - i - 1 > 0 || (this.flyweight.scrollTop = i * l, this.scroll());
|
|
@@ -113,16 +127,16 @@ const H = {
|
|
|
113
127
|
},
|
|
114
128
|
lazyrun(t, e) {
|
|
115
129
|
clearTimeout(this.time), this.time = setTimeout(() => {
|
|
116
|
-
|
|
130
|
+
y(t);
|
|
117
131
|
}, e || this.lazy);
|
|
118
132
|
},
|
|
119
133
|
run(t) {
|
|
120
134
|
let e = x(t.target, "scrollTop=>top");
|
|
121
135
|
m(
|
|
122
136
|
this.flyweights,
|
|
123
|
-
(i, l, s,
|
|
124
|
-
if (s = i / h >> 0, f = s +
|
|
125
|
-
(+(s <
|
|
137
|
+
(i, l, s, r, h, n, f, c) => {
|
|
138
|
+
if (s = i / h >> 0, f = s + r * /* 偏移量, 如果超出顶部 + 1轮,排列到列队后, 否则保持在当前*/
|
|
139
|
+
(+(s < n % r) + (n / r >> 0)), c = f * h + i % h, c >= this.count) {
|
|
126
140
|
this.lazyrun(() => this.$emit("onend", !0));
|
|
127
141
|
return;
|
|
128
142
|
}
|
|
@@ -143,25 +157,25 @@ const H = {
|
|
|
143
157
|
this.$nextTick(() => {
|
|
144
158
|
let [i, l] = this.offset, s = this.width;
|
|
145
159
|
s == 0 && (s = e.width);
|
|
146
|
-
let
|
|
147
|
-
this.row = f + 2, this.column =
|
|
148
|
-
let c = e.width %
|
|
149
|
-
this.Height = Math.ceil(this.count /
|
|
150
|
-
let u = Math.min(this.count,
|
|
160
|
+
let r = s + i, h = this.height + l, n = e.width / r >> 0, f = e.height / h >> 0;
|
|
161
|
+
this.row = f + 2, this.column = n, this.fwheight = h;
|
|
162
|
+
let c = e.width % r / (n - 1) >> 0;
|
|
163
|
+
this.Height = Math.ceil(this.count / n) * h;
|
|
164
|
+
let u = Math.min(this.count, n * this.row), a = u - 1, o, p;
|
|
151
165
|
for (; u-- > 0; )
|
|
152
166
|
o = a - u, p = this.flys[o], t = this.flyweights[o], this.$set(this.flyweights, o, {
|
|
153
167
|
data: p,
|
|
154
|
-
top: (o /
|
|
155
|
-
left: o %
|
|
156
|
-
index: o /
|
|
168
|
+
top: (o / n >> 0) * h,
|
|
169
|
+
left: o % n * (r + c),
|
|
170
|
+
index: o / n >> 0
|
|
157
171
|
});
|
|
158
172
|
this.flyweights.length = a + 1, this.scroll();
|
|
159
173
|
});
|
|
160
174
|
}
|
|
161
175
|
}
|
|
162
176
|
};
|
|
163
|
-
function
|
|
164
|
-
return
|
|
177
|
+
function L(t, e, i, l, s, r) {
|
|
178
|
+
return d(), g("div", {
|
|
165
179
|
ref: "flyweight",
|
|
166
180
|
class: k(["flyweight", {
|
|
167
181
|
"flyweight-active": s.actice
|
|
@@ -170,7 +184,7 @@ function O(t, e, i, l, s, n) {
|
|
|
170
184
|
"--width": i.width ? i.width + "px" : "100%",
|
|
171
185
|
"--height": i.height + "px"
|
|
172
186
|
}),
|
|
173
|
-
onScroll: e[0] || (e[0] = (...h) =>
|
|
187
|
+
onScroll: e[0] || (e[0] = (...h) => r.scroll && r.scroll(...h))
|
|
174
188
|
}, [
|
|
175
189
|
v("div", {
|
|
176
190
|
class: "flyweight-all",
|
|
@@ -178,8 +192,8 @@ function O(t, e, i, l, s, n) {
|
|
|
178
192
|
"--flyweight-height": s.Height + "px"
|
|
179
193
|
})
|
|
180
194
|
}, [
|
|
181
|
-
(
|
|
182
|
-
key:
|
|
195
|
+
(d(!0), g(b, null, z(s.flyweights, (h, n) => (d(), g("div", {
|
|
196
|
+
key: n,
|
|
183
197
|
style: w({
|
|
184
198
|
top: h.top + "px",
|
|
185
199
|
left: h.left + "px"
|
|
@@ -194,14 +208,14 @@ function O(t, e, i, l, s, n) {
|
|
|
194
208
|
s.flyweights.length ? _(t.$slots, "end", { key: 0 }, void 0, !0) : T("", !0)
|
|
195
209
|
], 38);
|
|
196
210
|
}
|
|
197
|
-
const
|
|
211
|
+
const O = /* @__PURE__ */ N(H, [["render", L], ["__scopeId", "data-v-075d9b23"]]), E = [O], S = {
|
|
198
212
|
install(t) {
|
|
199
|
-
|
|
213
|
+
E.forEach((e) => {
|
|
200
214
|
t.component("s-" + e.name.toLowerCase(), e);
|
|
201
215
|
});
|
|
202
216
|
}
|
|
203
217
|
};
|
|
204
218
|
export {
|
|
205
|
-
|
|
219
|
+
O as Flyweight,
|
|
206
220
|
S as default
|
|
207
221
|
};
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.flyweight[data-v-
|
|
1
|
+
.flyweight[data-v-075d9b23]{height:100%;width:100%;overflow:auto;position:relative}.flyweight .flyweight-all[data-v-075d9b23]{height:var(--flyweight-height)}.flyweight .flyweight-all[data-v-075d9b23]>*{width:var(--width);height:var(--height);position:absolute}
|
package/package.json
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
"name": "@soei/flyweight",
|
|
3
3
|
"private": false,
|
|
4
4
|
"description": "Vue组件, 列表de享元模式~减少DOM节点 flyweight",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.4",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/Flyweight.cjs",
|
|
8
8
|
"module": "dist/Flyweight.js",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist",
|
|
10
|
+
"dist/Flyweight.cjs",
|
|
11
|
+
"dist/Flyweight.js",
|
|
12
|
+
"dist/style.css",
|
|
11
13
|
"src/Flyweight.vue"
|
|
12
14
|
],
|
|
13
15
|
"scripts": {
|
|
@@ -16,12 +18,12 @@
|
|
|
16
18
|
"preview": "vite preview"
|
|
17
19
|
},
|
|
18
20
|
"dependencies": {
|
|
19
|
-
"@soei/util": "^1.1.1"
|
|
20
|
-
"vue": "^3.3.4"
|
|
21
|
+
"@soei/util": "^1.1.1"
|
|
21
22
|
},
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
23
|
+
"keywords": [
|
|
24
|
+
"Flyweight",
|
|
25
|
+
"享元模式",
|
|
26
|
+
"List",
|
|
27
|
+
"列表展示"
|
|
28
|
+
]
|
|
27
29
|
}
|
package/src/Flyweight.vue
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
<div ref="flyweight" class="flyweight" :class="{
|
|
3
3
|
'flyweight-active': actice
|
|
4
4
|
}" :style="{
|
|
5
|
-
'--width':
|
|
6
|
-
'--height':
|
|
5
|
+
'--width': realW + 'px',
|
|
6
|
+
'--height': realH + 'px'
|
|
7
7
|
}" @scroll="scroll">
|
|
8
8
|
<div class="flyweight-all" :style="{
|
|
9
9
|
'--flyweight-height': Height + 'px'
|
|
10
10
|
}">
|
|
11
|
-
<div v-for="(item, index) in flyweights" :key="index" :style="{
|
|
11
|
+
<div v-for="(item, index) in flyweights" :key="index" :data="item.top" :style="{
|
|
12
12
|
top: item.top + 'px',
|
|
13
13
|
left: item.left + 'px',
|
|
14
14
|
}">
|
|
@@ -26,10 +26,43 @@ let isNil = (data) => {
|
|
|
26
26
|
return data == null || data == undefined;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
let Rs = /(\d+|[+\-\*/]|%)/g;
|
|
30
|
+
|
|
31
|
+
let math = {
|
|
32
|
+
'+': (a, b) => a + b,
|
|
33
|
+
'-': (a, b) => a - b,
|
|
34
|
+
'*': (a, b) => a * b,
|
|
35
|
+
'/': (a, b) => a / b,
|
|
36
|
+
'%': (a, b, c) => parseFloat(a) / 100 * c,
|
|
37
|
+
}
|
|
38
|
+
/* 从左到右顺序计算, 100% - 100px px单位会被忽略 */
|
|
39
|
+
let computer = (W, width) => {
|
|
40
|
+
let data;
|
|
41
|
+
if (data = runer('match', W, Rs)) {
|
|
42
|
+
let mark = data.length, re, T = 0, op, args = [];
|
|
43
|
+
while (mark--) {
|
|
44
|
+
T = data.shift();
|
|
45
|
+
if (T in math) {
|
|
46
|
+
re && args.push(re);
|
|
47
|
+
if (T === '%') args.length = 2;
|
|
48
|
+
op = T;
|
|
49
|
+
} else {
|
|
50
|
+
+T && args.push(+T)
|
|
51
|
+
}
|
|
52
|
+
if (args.length == 2) {
|
|
53
|
+
args.push(width);
|
|
54
|
+
re = math[op].apply(null, args);
|
|
55
|
+
args.length = 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (!(+re)) re = +args.pop()
|
|
59
|
+
W = re >> 0;
|
|
60
|
+
}
|
|
61
|
+
return W;
|
|
62
|
+
}
|
|
29
63
|
let Log = (...args) => {
|
|
30
64
|
console.info('::::FLYWEIGHT', ...args);
|
|
31
65
|
}
|
|
32
|
-
|
|
33
66
|
export default {
|
|
34
67
|
name: 'Flyweight',
|
|
35
68
|
props: {
|
|
@@ -60,6 +93,14 @@ export default {
|
|
|
60
93
|
index: {
|
|
61
94
|
type: Number,
|
|
62
95
|
default: 0
|
|
96
|
+
},
|
|
97
|
+
top: {
|
|
98
|
+
type: Number,
|
|
99
|
+
default: false
|
|
100
|
+
},
|
|
101
|
+
left: {
|
|
102
|
+
type: Number,
|
|
103
|
+
default: false
|
|
63
104
|
}
|
|
64
105
|
},
|
|
65
106
|
computed: {
|
|
@@ -77,7 +118,9 @@ export default {
|
|
|
77
118
|
fwheight: 10,
|
|
78
119
|
|
|
79
120
|
count: 0,
|
|
80
|
-
task: []
|
|
121
|
+
task: [],
|
|
122
|
+
realW: 0,
|
|
123
|
+
realH: 0
|
|
81
124
|
}
|
|
82
125
|
},
|
|
83
126
|
watch: {
|
|
@@ -99,6 +142,12 @@ export default {
|
|
|
99
142
|
},
|
|
100
143
|
index(index) {
|
|
101
144
|
this.setindex(index);
|
|
145
|
+
},
|
|
146
|
+
top(top) {
|
|
147
|
+
this.flyweight.scrollTop = top;
|
|
148
|
+
},
|
|
149
|
+
left(left) {
|
|
150
|
+
this.flyweight.scrollLeft = left;
|
|
102
151
|
}
|
|
103
152
|
},
|
|
104
153
|
mounted() {
|
|
@@ -119,6 +168,9 @@ export default {
|
|
|
119
168
|
}
|
|
120
169
|
},
|
|
121
170
|
methods: {
|
|
171
|
+
trigger(key) {
|
|
172
|
+
this.lazyrun(() => this.$emit(key, true));
|
|
173
|
+
},
|
|
122
174
|
cheackflys(data) {
|
|
123
175
|
let length = this.flys.length;
|
|
124
176
|
if (!length) {
|
|
@@ -169,11 +221,11 @@ export default {
|
|
|
169
221
|
i = index * column + k % column;
|
|
170
222
|
|
|
171
223
|
if (i >= this.count) {
|
|
172
|
-
this.
|
|
224
|
+
this.trigger('onend');
|
|
173
225
|
return /* true */;
|
|
174
226
|
}
|
|
175
227
|
v.index = index;
|
|
176
|
-
v.top =
|
|
228
|
+
v.top = index * this.fwheight;
|
|
177
229
|
v.data = this.flys[i];
|
|
178
230
|
},
|
|
179
231
|
null,
|
|
@@ -186,45 +238,47 @@ export default {
|
|
|
186
238
|
scroll(e) {
|
|
187
239
|
this.run(e || { target: this.flyweight });
|
|
188
240
|
},
|
|
189
|
-
|
|
190
241
|
re() {
|
|
242
|
+
let size = this.count || this.flys.length;
|
|
243
|
+
let fws = this.flyweights;
|
|
244
|
+
if (!size) return fws.length = size;
|
|
191
245
|
let flyweight = this.flyweight;
|
|
192
246
|
let wh = picker(flyweight, 'clientHeight=>height,clientWidth=>width');
|
|
193
247
|
this.$nextTick(() => {
|
|
194
|
-
let [x, y] = this.offset,
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
let
|
|
200
|
-
|
|
201
|
-
let column = wh.width / width >> 0,
|
|
202
|
-
row = wh.height / height >> 0;
|
|
248
|
+
let [x, y] = this.offset, W = wh.width, H = wh.height;
|
|
249
|
+
let width = (computer(this.width, W) || W) + x;
|
|
250
|
+
let height = computer(this.height, H) + y/* 偏移量填充宽度 */;
|
|
251
|
+
this.realW = width - x;
|
|
252
|
+
this.realH = height - y/* 实际高度减掉偏移量 */;
|
|
253
|
+
let column = (W / width >> 0) || 1,
|
|
254
|
+
row = H / height >> 0;
|
|
203
255
|
this.row = row + 2/* 上下各一行补位 */;
|
|
204
256
|
this.column = column;
|
|
205
257
|
this.fwheight = height;
|
|
258
|
+
let offset = W % width;
|
|
206
259
|
/* 偏移量 */
|
|
207
|
-
let margin =
|
|
260
|
+
let margin = offset / (column - 1) >> 0;
|
|
208
261
|
/* 总高度 */
|
|
209
|
-
this.Height = Math.ceil(
|
|
262
|
+
this.Height = Math.ceil(size / column) * height;
|
|
210
263
|
/* 计算数量 */
|
|
211
|
-
let count = Math.min(
|
|
264
|
+
let count = Math.min(size, column * this.row),
|
|
212
265
|
length = count - 1,
|
|
213
266
|
index,
|
|
214
267
|
fly;
|
|
215
268
|
while (count-- > 0) {
|
|
216
269
|
index = length - count;
|
|
217
270
|
fly = this.flys[index];
|
|
218
|
-
flyweight =
|
|
219
|
-
|
|
271
|
+
flyweight = fws[index];
|
|
272
|
+
row = index / column >> 0;
|
|
273
|
+
this.$set(fws, index, {
|
|
220
274
|
data: fly,
|
|
221
|
-
top:
|
|
275
|
+
top: row * height,
|
|
222
276
|
left: (index % column) * (width + margin),
|
|
223
|
-
index:
|
|
277
|
+
index: row
|
|
224
278
|
})
|
|
225
279
|
}
|
|
226
|
-
|
|
227
|
-
|
|
280
|
+
fws.length = length + 1;
|
|
281
|
+
if (H / height > length) this.trigger('onend');
|
|
228
282
|
this.scroll()
|
|
229
283
|
});
|
|
230
284
|
}
|
|
@@ -243,7 +297,7 @@ export default {
|
|
|
243
297
|
height: var(--flyweight-height);
|
|
244
298
|
|
|
245
299
|
&>* {
|
|
246
|
-
width: var(--width);
|
|
300
|
+
width: calc(var(--width));
|
|
247
301
|
height: var(--height);
|
|
248
302
|
position: absolute;
|
|
249
303
|
}
|
package/dist/vite.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|