@soei/flyweight 0.0.7 → 0.0.9

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/README.md CHANGED
@@ -9,16 +9,63 @@
9
9
 
10
10
  ### 更新日志
11
11
 
12
- ### `0.0.7`
12
+ ### `0.0.9`
13
13
 
14
- - #### 新增 `:auto`, 默认值: `false`
14
+ - #### 问题修复 `v-model:space` onend 冲突问题处理
15
+
16
+ ### `0.0.8`
17
+
18
+ - #### 新增 `v-model:space`, 计算空间显示 `行` 与 `列`
15
19
 
16
- `auto` `true` 时, `:width` 赋值会被视为 `最小值`, 剩余空间自动填充
20
+ 被通知对象 `notice`: {`row`, `column`}
17
21
 
18
22
  ```html
19
- <s-flyweight :auto="true" :width="100"></s-flyweight>
23
+ <!-- eg.
24
+ 当有5个元素,
25
+ 当: :width="100% / 3", column = 3列, row = 2,
26
+ 当: :width="100% / 5", column = 5列, row = 1,
27
+ 当: :width="100% / 7", column = 7列, row = 1
28
+ ...
29
+ -->
30
+ <!-- VUE3 -->
31
+ <template>
32
+ <s-flyweight v-model:space="notice"></s-flyweight>
33
+ </template>
34
+ <script setup>
35
+ let notice = ref({ row: 0, column: 0 });
36
+ watch(
37
+ () => notice.value,
38
+ (val) => {
39
+ console.log(val);
40
+ }
41
+ );
42
+ </script>
43
+
44
+ <!-- VUE2 -->
45
+ <template>
46
+ <s-flyweight :space.sync="notice"></s-flyweight>
47
+ </template>
48
+ <script>
49
+ export default {
50
+ data() {
51
+ return {
52
+ notice: { row: 0, column: 0 },
53
+ };
54
+ },
55
+ };
56
+ </script>
20
57
  ```
21
58
 
59
+ ### `0.0.7`
60
+
61
+ - #### 新增 `:auto`, 默认值: `false`
62
+
63
+ 当 `auto` 为 `true` 时, `:width` 赋值会被视为 `最小值`, 剩余空间自动填充
64
+
65
+ ```html
66
+ <s-flyweight :auto="true" :width="100"></s-flyweight>
67
+ ```
68
+
22
69
  ### `0.0.6`
23
70
 
24
71
  - #### 优化 `flys` 初始化赋值,不改变时,获取 length 问题
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("@soei/util"),o=require("vue");const b=(e,t)=>{const l=e.__vccOpts||e;for(const[n,i]of t)l[n]=i;return l};let z=e=>e==null||e==null,T=/(\d+|[+\-\*/]|%)/g,x={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t,l)=>parseFloat(e)/100*l},_=(e,t)=>{let l;if(l=a.runer("match",e,T)){let n=l.length,i,s=0,h,r=[];for(;n--;)s=l.shift(),s in x?(i&&r.push(i),s==="%"&&(r.length=2),h=s):+s&&r.push(+s),r.length==2&&(r.push(t),i=x[h].apply(null,r),r.length=0);+i||(i=+r.pop()),e=i>>0}return e},H=(...e)=>{console.info("::::FLYWEIGHT",...e)};const N={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},auto:{type:[Boolean,String],default:!1}},computed:{flyweight(){return this.$refs.flyweight}},data(){return{flyweights:[],actice:!1,Height:null,column:1,row:1,fwheight:10,count:0,task:[],realW:0,realH:0}},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,l)=>{e[t]=l}),this.setindex(this.index);try{new ResizeObserver(()=>{this.re(),this.$emit("resize")}).observe(this.flyweight)}catch(e){H(e)}},methods:{trigger(e){this.lazyrun(()=>this.$emit(e,!0))},cheackflys(e){if(!this.flys.length)return e&&this.task.push(e),!0},setview(e){a.runer([this.cheackflys,t=>{t=t||{};let l=t.index||a.each(this.flys,(n,i,s,h)=>{if(i[s]==h)return n},t.picker,t.id);z(l)||this.setindex(l)}],this,e)},setindex(e){a.runer([this.cheackflys,({index:t})=>{this.$nextTick(()=>{let l=t/this.column>>0,n=this.fwheight;(this.flyweight.scrollTop/n>>0)+this.row-l-1>0||(this.flyweight.scrollTop=l*n,this.scroll())})}],this,{index:e})},lazyrun(e,t){clearTimeout(this.time),this.time=setTimeout(()=>{a.runer(e)},t||this.lazy)},run(e){let t=a.picker(e.target,"scrollTop=>top");a.each(this.flyweights,(l,n,i,s,h,r,u,f)=>{if(i=l/h>>0,u=i+s*(+(i<r%s)+(r/s>>0)),f=u*h+l%h,f>=this.count){this.trigger("onend");return}n.index=u,n.top=u*this.fwheight,n.data=this.flys[f]},null,this.row,this.column,t.top/this.fwheight>>0)},scroll(e){this.run(e||{target:this.flyweight})},re(){let e=this.count||this.flys.length,t=this.flyweights;if(!e)return t.length=e;this.count=e;let l=this.flyweight,n=a.picker(l,"clientHeight=>height,clientWidth=>width");this.$nextTick(()=>{let i=this.auto===!0,[s,h]=this.offset,r=n.width,u=n.height,f=(_(this.width,r)||r)+s,g=_(this.height,u)+h;this.realW=f-s,this.realH=g-h;let c=r/f>>0||1,d=u/g>>0;this.row=d+2,this.column=c,this.fwheight=g;let m=r%f/(c-1*+!i)>>0;i&&(f=this.realW=(r/c>>0)-s,m=s),this.Height=Math.ceil(e/c)*g;let p=Math.min(e,c*this.row),w=p-1,y,k;for(;p-- >0;)y=w-p,k=this.flys[y],l=t[y],d=y/c>>0,this.$set(t,y,{data:k,top:d*g,left:y%c*(f+m),index:d});t.length=w+1,u/g>w&&this.trigger("onend"),this.scroll()})}}},S=["data"];function B(e,t,l,n,i,s){return o.openBlock(),o.createElementBlock("div",{ref:"flyweight",class:o.normalizeClass(["flyweight",{"flyweight-active":i.actice}]),style:o.normalizeStyle({"--width":i.realW+"px","--height":i.realH+"px"}),onScroll:t[0]||(t[0]=(...h)=>s.scroll&&s.scroll(...h))},[o.createElementVNode("div",{class:"flyweight-all",style:o.normalizeStyle({"--flyweight-height":i.Height+"px"})},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(i.flyweights,(h,r)=>(o.openBlock(),o.createElementBlock("div",{key:r,data:h.top,style:o.normalizeStyle({top:h.top+"px",left:h.left+"px"})},[o.renderSlot(e.$slots,"default",{data:h.data,index:h.index},void 0,!0)],12,S))),128))],4),i.flyweights.length?o.renderSlot(e.$slots,"end",{key:0},void 0,!0):o.createCommentVNode("",!0)],38)}const v=b(N,[["render",B],["__scopeId","data-v-144a29f8"]]),F=[v],$={install(e){F.forEach(t=>{e.component("s-"+t.name.toLowerCase(),t)})}};exports.Flyweight=v;exports.default=$;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("@soei/util"),o=require("vue");const T=(e,t)=>{const l=e.__vccOpts||e;for(const[h,i]of t)l[h]=i;return l};let k=e=>e==null||e==null,H=/(\d+|[+\-\*/]|%)/g,b={"+":(e,t)=>e+t,"-":(e,t)=>e-t,"*":(e,t)=>e*t,"/":(e,t)=>e/t,"%":(e,t,l)=>parseFloat(e)/100*l},v=(e,t)=>{let l;if(l=f.runer("match",e,H)){let h=l.length,i,s=0,r,n=[];for(;h--;)s=l.shift(),s in b?(i&&n.push(i),s==="%"&&(n.length=2),r=s):+s&&n.push(+s),n.length==2&&(n.push(t),i=b[r].apply(null,n),n.length=0);+i||(i=+n.pop()),e=i>>0}return e},N=(...e)=>{console.info("::::FLYWEIGHT",...e)};const S={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},auto:{type:[Boolean,String],default:!1},space:{type:Object,default:()=>null}},computed:{flyweight(){return this.$refs.flyweight}},data(){return{flyweights:[],actice:!1,Height:null,column:1,row:1,fwheight:10,count:0,task:[],realW:0,realH:0}},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,l)=>{e[t]=l}),this.setindex(this.index);try{new ResizeObserver(()=>{this.re(),this.$emit("resize")}).observe(this.flyweight)}catch(e){N(e)}},methods:{trigger(e,t){this.lazyrun(()=>{f.isArray(e)||(e=[[e,t]]),f.each(e,(l,h)=>{this.$emit(h[0],k(h[1])?!0:h[1])})})},cheackflys(e){if(!this.flys.length)return e&&this.task.push(e),!0},setview(e){f.runer([this.cheackflys,t=>{t=t||{};let l=t.index||f.each(this.flys,(h,i,s,r)=>{if(i[s]==r)return h},t.picker,t.id);k(l)||this.setindex(l)}],this,e)},setindex(e){f.runer([this.cheackflys,({index:t})=>{this.$nextTick(()=>{let l=t/this.column>>0,h=this.fwheight;(this.flyweight.scrollTop/h>>0)+this.row-l-1>0||(this.flyweight.scrollTop=l*h,this.scroll())})}],this,{index:e})},lazyrun(e,t){clearTimeout(this.time),this.time=setTimeout(()=>{f.runer(e)},t||this.lazy)},run(e){let t=f.picker(e.target,"scrollTop=>top");f.each(this.flyweights,(l,h,i,s,r,n,a,u)=>{if(i=l/r>>0,a=i+s*(+(i<n%s)+(n/s>>0)),u=a*r+l%r,u>=this.count){this.trigger("onend");return}h.index=a,h.top=a*this.fwheight,h.data=this.flys[u]},null,this.row,this.column,t.top/this.fwheight>>0)},scroll(e){this.run(e||{target:this.flyweight})},re(){let e=this.count||this.flys.length,t=this.flyweights;if(!e)return t.length=e;this.count=e;let l=this.flyweight,h=f.picker(l,"clientHeight=>height,clientWidth=>width");this.$nextTick(()=>{let i=this.auto===!0,[s,r]=this.offset,n=h.width,a=h.height,u=(v(this.width,n)||n)+s,g=v(this.height,a)+r;this.realW=u-s,this.realH=g-r;let c=n/u>>0||1,y=a/g>>0;this.row=y+2,this.column=c,this.fwheight=g;let x=n%u/(c-1*+!i)>>0;i&&(u=this.realW=(n/c>>0)-s,x=s),this.Height=Math.ceil(e/c)*g;let w=Math.min(e,c*this.row),p=w-1,d,_;for(;w-- >0;)d=p-w,_=this.flys[d],l=t[d],y=d/c>>0,this.$set(t,d,{data:_,top:y*g,left:d%c*(u+x),index:y});t.length=p+1;let m=[];a/g>p&&m.push(["onend"]),this.scroll(),m.push(["update:space",{row:(p/c>>0)+1,column:c}]),this.trigger(m)})}}},B=["data"];function F(e,t,l,h,i,s){return o.openBlock(),o.createElementBlock("div",{ref:"flyweight",class:o.normalizeClass(["flyweight",{"flyweight-active":i.actice}]),style:o.normalizeStyle({"--width":i.realW+"px","--height":i.realH+"px"}),onScroll:t[0]||(t[0]=(...r)=>s.scroll&&s.scroll(...r))},[o.createElementVNode("div",{class:"flyweight-all",style:o.normalizeStyle({"--flyweight-height":i.Height+"px"})},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(i.flyweights,(r,n)=>(o.openBlock(),o.createElementBlock("div",{key:n,data:r.top,style:o.normalizeStyle({top:r.top+"px",left:r.left+"px"})},[o.renderSlot(e.$slots,"default",{data:r.data,index:r.index},void 0,!0)],12,B))),128))],4),i.flyweights.length?o.renderSlot(e.$slots,"end",{key:0},void 0,!0):o.createCommentVNode("",!0)],38)}const z=T(S,[["render",F],["__scopeId","data-v-1342d2cb"]]),O=[z],$={install(e){O.forEach(t=>{e.component("s-"+t.name.toLowerCase(),t)})}};exports.Flyweight=z;exports.default=$;
package/dist/Flyweight.js CHANGED
@@ -1,30 +1,30 @@
1
- import { runer as y, each as v, picker as b } from "@soei/util";
2
- import { openBlock as w, createElementBlock as m, normalizeClass as N, normalizeStyle as x, createElementVNode as $, Fragment as F, renderList as L, renderSlot as z, createCommentVNode as O } from "vue";
3
- const W = (t, e) => {
1
+ import { isArray as F, each as m, runer as d, picker as z } from "@soei/util";
2
+ import { openBlock as x, createElementBlock as _, normalizeClass as O, normalizeStyle as b, createElementVNode as L, Fragment as W, renderList as E, renderSlot as T, createCommentVNode as S } from "vue";
3
+ const A = (t, e) => {
4
4
  const s = t.__vccOpts || t;
5
- for (const [n, i] of e)
6
- s[n] = i;
5
+ for (const [h, i] of e)
6
+ s[h] = i;
7
7
  return s;
8
8
  };
9
- let E = (t) => t == null || t == null, S = /(\d+|[+\-\*/]|%)/g, T = {
9
+ let H = (t) => t == null || t == null, B = /(\d+|[+\-\*/]|%)/g, N = {
10
10
  "+": (t, e) => t + e,
11
11
  "-": (t, e) => t - e,
12
12
  "*": (t, e) => t * e,
13
13
  "/": (t, e) => t / e,
14
14
  "%": (t, e, s) => parseFloat(t) / 100 * s
15
- }, H = (t, e) => {
15
+ }, $ = (t, e) => {
16
16
  let s;
17
- if (s = y("match", t, S)) {
18
- let n = s.length, i, l = 0, h, r = [];
19
- for (; n--; )
20
- l = s.shift(), l in T ? (i && r.push(i), l === "%" && (r.length = 2), h = l) : +l && r.push(+l), r.length == 2 && (r.push(e), i = T[h].apply(null, r), r.length = 0);
21
- +i || (i = +r.pop()), t = i >> 0;
17
+ if (s = d("match", t, B)) {
18
+ let h = s.length, i, l = 0, r, n = [];
19
+ for (; h--; )
20
+ l = s.shift(), l in N ? (i && n.push(i), l === "%" && (n.length = 2), r = l) : +l && n.push(+l), n.length == 2 && (n.push(e), i = N[r].apply(null, n), n.length = 0);
21
+ +i || (i = +n.pop()), t = i >> 0;
22
22
  }
23
23
  return t;
24
- }, B = (...t) => {
24
+ }, C = (...t) => {
25
25
  console.info("::::FLYWEIGHT", ...t);
26
26
  };
27
- const C = {
27
+ const I = {
28
28
  name: "Flyweight",
29
29
  props: {
30
30
  flys: {
@@ -66,6 +66,10 @@ const C = {
66
66
  auto: {
67
67
  type: [Boolean, String],
68
68
  default: !1
69
+ },
70
+ space: {
71
+ type: Object,
72
+ default: () => null
69
73
  }
70
74
  },
71
75
  computed: {
@@ -120,51 +124,55 @@ const C = {
120
124
  this.re(), this.$emit("resize");
121
125
  }).observe(this.flyweight);
122
126
  } catch (t) {
123
- B(t);
127
+ C(t);
124
128
  }
125
129
  },
126
130
  methods: {
127
- trigger(t) {
128
- this.lazyrun(() => this.$emit(t, !0));
131
+ trigger(t, e) {
132
+ this.lazyrun(() => {
133
+ F(t) || (t = [[t, e]]), m(t, (s, h) => {
134
+ this.$emit(h[0], H(h[1]) ? !0 : h[1]);
135
+ });
136
+ });
129
137
  },
130
138
  cheackflys(t) {
131
139
  if (!this.flys.length)
132
140
  return t && this.task.push(t), !0;
133
141
  },
134
142
  setview(t) {
135
- y([this.cheackflys, (e) => {
143
+ d([this.cheackflys, (e) => {
136
144
  e = e || {};
137
- let s = e.index || v(this.flys, (n, i, l, h) => {
138
- if (i[l] == h)
139
- return n;
145
+ let s = e.index || m(this.flys, (h, i, l, r) => {
146
+ if (i[l] == r)
147
+ return h;
140
148
  }, e.picker, e.id);
141
- E(s) || this.setindex(s);
149
+ H(s) || this.setindex(s);
142
150
  }], this, t);
143
151
  },
144
152
  setindex(t) {
145
- y([this.cheackflys, ({ index: e }) => {
153
+ d([this.cheackflys, ({ index: e }) => {
146
154
  this.$nextTick(() => {
147
- let s = e / this.column >> 0, n = this.fwheight;
148
- (this.flyweight.scrollTop / n >> 0) + this.row - s - 1 > 0 || (this.flyweight.scrollTop = s * n, this.scroll());
155
+ let s = e / this.column >> 0, h = this.fwheight;
156
+ (this.flyweight.scrollTop / h >> 0) + this.row - s - 1 > 0 || (this.flyweight.scrollTop = s * h, this.scroll());
149
157
  });
150
158
  }], this, { index: t });
151
159
  },
152
160
  lazyrun(t, e) {
153
161
  clearTimeout(this.time), this.time = setTimeout(() => {
154
- y(t);
162
+ d(t);
155
163
  }, e || this.lazy);
156
164
  },
157
165
  run(t) {
158
- let e = b(t.target, "scrollTop=>top");
159
- v(
166
+ let e = z(t.target, "scrollTop=>top");
167
+ m(
160
168
  this.flyweights,
161
- (s, n, i, l, h, r, f, o) => {
162
- if (i = s / h >> 0, f = i + l * /* 偏移量, 如果超出顶部 + 1轮,排列到列队后, 否则保持在当前*/
163
- (+(i < r % l) + (r / l >> 0)), o = f * h + s % h, o >= this.count) {
169
+ (s, h, i, l, r, n, u, o) => {
170
+ if (i = s / r >> 0, u = i + l * /* 偏移量, 如果超出顶部 + 1轮,排列到列队后, 否则保持在当前*/
171
+ (+(i < n % l) + (n / l >> 0)), o = u * r + s % r, o >= this.count) {
164
172
  this.trigger("onend");
165
173
  return;
166
174
  }
167
- n.index = f, n.top = f * this.fwheight, n.data = this.flys[o];
175
+ h.index = u, h.top = u * this.fwheight, h.data = this.flys[o];
168
176
  },
169
177
  null,
170
178
  this.row,
@@ -181,70 +189,72 @@ const C = {
181
189
  if (!t)
182
190
  return e.length = t;
183
191
  this.count = t;
184
- let s = this.flyweight, n = b(s, "clientHeight=>height,clientWidth=>width");
192
+ let s = this.flyweight, h = z(s, "clientHeight=>height,clientWidth=>width");
185
193
  this.$nextTick(() => {
186
- let i = this.auto === !0, [l, h] = this.offset, r = n.width, f = n.height, o = (H(this.width, r) || r) + l, u = H(this.height, f) + h;
187
- this.realW = o - l, this.realH = u - h;
188
- let a = r / o >> 0 || 1, g = f / u >> 0;
189
- this.row = g + 2, this.column = a, this.fwheight = u;
190
- let _ = r % o / (a - 1 * +!i) >> 0;
191
- i && (o = this.realW = (r / a >> 0) - l, _ = l), this.Height = Math.ceil(t / a) * u;
192
- let d = Math.min(t, a * this.row), p = d - 1, c, k;
193
- for (; d-- > 0; )
194
- c = p - d, k = this.flys[c], s = e[c], g = c / a >> 0, this.$set(e, c, {
195
- data: k,
196
- top: g * u,
197
- left: c % a * (o + _),
194
+ let i = this.auto === !0, [l, r] = this.offset, n = h.width, u = h.height, o = ($(this.width, n) || n) + l, a = $(this.height, u) + r;
195
+ this.realW = o - l, this.realH = a - r;
196
+ let f = n / o >> 0 || 1, g = u / a >> 0;
197
+ this.row = g + 2, this.column = f, this.fwheight = a;
198
+ let k = n % o / (f - 1 * +!i) >> 0;
199
+ i && (o = this.realW = (n / f >> 0) - l, k = l), this.Height = Math.ceil(t / f) * a;
200
+ let y = Math.min(t, f * this.row), p = y - 1, c, v;
201
+ for (; y-- > 0; )
202
+ c = p - y, v = this.flys[c], s = e[c], g = c / f >> 0, this.$set(e, c, {
203
+ data: v,
204
+ top: g * a,
205
+ left: c % f * (o + k),
198
206
  index: g
199
207
  });
200
- e.length = p + 1, f / u > p && this.trigger("onend"), this.scroll();
208
+ e.length = p + 1;
209
+ let w = [];
210
+ u / a > p && w.push(["onend"]), this.scroll(), w.push(["update:space", { row: (p / f >> 0) + 1, column: f }]), this.trigger(w);
201
211
  });
202
212
  }
203
213
  }
204
- }, I = ["data"];
205
- function A(t, e, s, n, i, l) {
206
- return w(), m("div", {
214
+ }, j = ["data"];
215
+ function M(t, e, s, h, i, l) {
216
+ return x(), _("div", {
207
217
  ref: "flyweight",
208
- class: N(["flyweight", {
218
+ class: O(["flyweight", {
209
219
  "flyweight-active": i.actice
210
220
  }]),
211
- style: x({
221
+ style: b({
212
222
  "--width": i.realW + "px",
213
223
  "--height": i.realH + "px"
214
224
  }),
215
- onScroll: e[0] || (e[0] = (...h) => l.scroll && l.scroll(...h))
225
+ onScroll: e[0] || (e[0] = (...r) => l.scroll && l.scroll(...r))
216
226
  }, [
217
- $("div", {
227
+ L("div", {
218
228
  class: "flyweight-all",
219
- style: x({
229
+ style: b({
220
230
  "--flyweight-height": i.Height + "px"
221
231
  })
222
232
  }, [
223
- (w(!0), m(F, null, L(i.flyweights, (h, r) => (w(), m("div", {
224
- key: r,
225
- data: h.top,
226
- style: x({
227
- top: h.top + "px",
228
- left: h.left + "px"
233
+ (x(!0), _(W, null, E(i.flyweights, (r, n) => (x(), _("div", {
234
+ key: n,
235
+ data: r.top,
236
+ style: b({
237
+ top: r.top + "px",
238
+ left: r.left + "px"
229
239
  })
230
240
  }, [
231
- z(t.$slots, "default", {
232
- data: h.data,
233
- index: h.index
241
+ T(t.$slots, "default", {
242
+ data: r.data,
243
+ index: r.index
234
244
  }, void 0, !0)
235
- ], 12, I))), 128))
245
+ ], 12, j))), 128))
236
246
  ], 4),
237
- i.flyweights.length ? z(t.$slots, "end", { key: 0 }, void 0, !0) : O("", !0)
247
+ i.flyweights.length ? T(t.$slots, "end", { key: 0 }, void 0, !0) : S("", !0)
238
248
  ], 38);
239
249
  }
240
- const M = /* @__PURE__ */ W(C, [["render", A], ["__scopeId", "data-v-144a29f8"]]), R = [M], U = {
250
+ const R = /* @__PURE__ */ A(I, [["render", M], ["__scopeId", "data-v-1342d2cb"]]), V = [R], q = {
241
251
  install(t) {
242
- R.forEach((e) => {
252
+ V.forEach((e) => {
243
253
  t.component("s-" + e.name.toLowerCase(), e);
244
254
  });
245
255
  }
246
256
  };
247
257
  export {
248
- M as Flyweight,
249
- U as default
258
+ R as Flyweight,
259
+ q as default
250
260
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .flyweight[data-v-144a29f8]{height:100%;width:100%;overflow:auto;position:relative}.flyweight .flyweight-all[data-v-144a29f8]{height:var(--flyweight-height)}.flyweight .flyweight-all[data-v-144a29f8]>*{width:calc(var(--width));height:var(--height);position:absolute}
1
+ .flyweight[data-v-1342d2cb]{height:100%;width:100%;overflow:auto;position:relative}.flyweight .flyweight-all[data-v-1342d2cb]{height:var(--flyweight-height)}.flyweight .flyweight-all[data-v-1342d2cb]>*{width:calc(var(--width));height:var(--height);position:absolute}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@soei/flyweight",
3
3
  "private": false,
4
4
  "description": "Vue组件, 列表de享元模式~减少DOM节点 flyweight",
5
- "version": "0.0.7",
5
+ "version": "0.0.9",
6
6
  "type": "module",
7
7
  "main": "dist/Flyweight.cjs",
8
8
  "module": "dist/Flyweight.js",
package/src/Flyweight.vue CHANGED
@@ -20,7 +20,7 @@
20
20
  </template>
21
21
 
22
22
  <script>
23
- import { each, picker, runer } from '@soei/util';
23
+ import { each, picker, runer, isArray } from '@soei/util';
24
24
  let isNil = (data) => {
25
25
  return data == null || data == undefined;
26
26
  }
@@ -104,6 +104,10 @@ export default {
104
104
  auto: {
105
105
  type: [Boolean, String],
106
106
  default: false
107
+ },
108
+ space: {
109
+ type: Object,
110
+ default: () => (null)
107
111
  }
108
112
  },
109
113
  computed: {
@@ -171,8 +175,13 @@ export default {
171
175
  }
172
176
  },
173
177
  methods: {
174
- trigger(key) {
175
- this.lazyrun(() => this.$emit(key, true));
178
+ trigger(key, data) {
179
+ this.lazyrun(() => {
180
+ if (!isArray(key)) key = [[key, data]];
181
+ each(key, (k, v) => {
182
+ this.$emit(v[0], isNil(v[1]) ? true : v[1]);
183
+ })
184
+ });
176
185
  },
177
186
  cheackflys(data) {
178
187
  let length = this.flys.length;
@@ -287,8 +296,13 @@ export default {
287
296
  })
288
297
  }
289
298
  fws.length = length + 1;
290
- if (H / height > length) this.trigger('onend');
291
- this.scroll()
299
+ let triggers = [];
300
+ if (H / height > length) triggers.push(['onend']);
301
+ this.scroll();
302
+ /* 计算占用空间 */
303
+ triggers.push(['update:space', { row: (length / column >> 0) + 1, column: column }]);
304
+
305
+ this.trigger(triggers);
292
306
  });
293
307
  }
294
308
  }