@soei/flyweight 0.0.8 → 0.0.10

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
@@ -1,14 +1,24 @@
1
- # 享元模式
1
+ ![安装](https://img.shields.io/badge/安装-npm_i_@soei/flyweight-ffc107?style=flat)
2
2
 
3
+ # 享元模式 [![Latest Version on NPM](https://img.shields.io/npm/v/@soei/flyweight?label=npm&style=flat-square)](https://npmjs.com/package/@soei/flyweight) [![Software License](https://img.shields.io/badge/license-ISC-brightgreen?label=&style=flat-square)](LICENSE.md) [![npm](https://img.shields.io/npm/dw/@soei/flyweight?label=Downloads&style=flat-square)](https://www.npmjs.com/package/@soei/flyweight) ![npm bundle size](https://img.shields.io/bundlephobia/min/%40soei%2Futil?label=Size&color=&style=flat-square)
4
+
5
+
6
+
7
+ ![安装](https://img.shields.io/badge/-@soei-ae8aff?style=flat-square)![NPM Downloads by package author](https://img.shields.io/npm-stat/dw/soeiz?style=flat-square)
3
8
  ```html
4
9
  <div style="height:100px;width:300px;">
5
10
  <!-- 确认父容器 宽 高 存在, 依赖父容器 `宽`, `高` 计算 -->
6
11
  <s-flyweight ...></s-flyweight>
7
12
  </div>
8
13
  ```
14
+ ![安装](https://img.shields.io/badge/引用-import_{_Flyweight_}_from_"@soei/flyweight"-00bcd4?style=flat-square)
9
15
 
10
16
  ### 更新日志
11
17
 
18
+ ### `0.0.9`
19
+
20
+ - #### 问题修复 `v-model:space` 和 onend 冲突问题处理
21
+
12
22
  ### `0.0.8`
13
23
 
14
24
  - #### 新增 `v-model:space`, 计算空间显示 `行` 与 `列`
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("@soei/util"),o=require("vue");const z=(e,t)=>{const l=e.__vccOpts||e;for(const[n,i]of t)l[n]=i;return l};let x=e=>e==null||e==null,T=/(\d+|[+\-\*/]|%)/g,_={"+":(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=c.runer("match",e,T)){let n=l.length,i,s=0,h,r=[];for(;n--;)s=l.shift(),s in _?(i&&r.push(i),s==="%"&&(r.length=2),h=s):+s&&r.push(+s),r.length==2&&(r.push(t),i=_[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},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){H(e)}},methods:{trigger(e,t){this.lazyrun(()=>this.$emit(e,x(t)?!0:t))},cheackflys(e){if(!this.flys.length)return e&&this.task.push(e),!0},setview(e){c.runer([this.cheackflys,t=>{t=t||{};let l=t.index||c.each(this.flys,(n,i,s,h)=>{if(i[s]==h)return n},t.picker,t.id);x(l)||this.setindex(l)}],this,e)},setindex(e){c.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(()=>{c.runer(e)},t||this.lazy)},run(e){let t=c.picker(e.target,"scrollTop=>top");c.each(this.flyweights,(l,n,i,s,h,r,a,f)=>{if(i=l/h>>0,a=i+s*(+(i<r%s)+(r/s>>0)),f=a*h+l%h,f>=this.count){this.trigger("onend");return}n.index=a,n.top=a*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=c.picker(l,"clientHeight=>height,clientWidth=>width");this.$nextTick(()=>{let i=this.auto===!0,[s,h]=this.offset,r=n.width,a=n.height,f=(v(this.width,r)||r)+s,g=v(this.height,a)+h;this.realW=f-s,this.realH=g-h;let u=r/f>>0||1,d=a/g>>0;this.row=d+2,this.column=u,this.fwheight=g;let m=r%f/(u-1*+!i)>>0;i&&(f=this.realW=(r/u>>0)-s,m=s),this.Height=Math.ceil(e/u)*g;let w=Math.min(e,u*this.row),p=w-1,y,k;for(;w-- >0;)y=p-w,k=this.flys[y],l=t[y],d=y/u>>0,this.$set(t,y,{data:k,top:d*g,left:y%u*(f+m),index:d});t.length=p+1,a/g>p&&this.trigger("onend"),this.scroll(),this.trigger("update:space",{row:(p/u>>0)+1,column:u})})}}},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 b=z(N,[["render",B],["__scopeId","data-v-84a26ea4"]]),F=[b],O={install(e){F.forEach(t=>{e.component("s-"+t.name.toLowerCase(),t)})}};exports.Flyweight=b;exports.default=O;
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 p, each as v, picker as b } from "@soei/util";
2
- import { openBlock as w, createElementBlock as m, normalizeClass as $, normalizeStyle as x, createElementVNode as F, Fragment as O, renderList as L, renderSlot as z, createCommentVNode as W } from "vue";
3
- const E = (t, e) => {
4
- const l = t.__vccOpts || t;
5
- for (const [n, i] of e)
6
- l[n] = i;
7
- return l;
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
+ const s = t.__vccOpts || t;
5
+ for (const [h, i] of e)
6
+ s[h] = i;
7
+ return s;
8
8
  };
9
- let T = (t) => t == null || t == null, S = /(\d+|[+\-\*/]|%)/g, H = {
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
- "%": (t, e, l) => parseFloat(t) / 100 * l
15
- }, N = (t, e) => {
16
- let l;
17
- if (l = p("match", t, S)) {
18
- let n = l.length, i, s = 0, h, r = [];
19
- for (; n--; )
20
- s = l.shift(), s in H ? (i && r.push(i), s === "%" && (r.length = 2), h = s) : +s && r.push(+s), r.length == 2 && (r.push(e), i = H[h].apply(null, r), r.length = 0);
21
- +i || (i = +r.pop()), t = i >> 0;
14
+ "%": (t, e, s) => parseFloat(t) / 100 * s
15
+ }, $ = (t, e) => {
16
+ let s;
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: {
@@ -116,59 +116,63 @@ const C = {
116
116
  }
117
117
  },
118
118
  mounted() {
119
- this.flyweights = [], this.$set || (this.$set = (t, e, l) => {
120
- t[e] = l;
119
+ this.flyweights = [], this.$set || (this.$set = (t, e, s) => {
120
+ t[e] = s;
121
121
  }), this.setindex(this.index);
122
122
  try {
123
123
  new ResizeObserver(() => {
124
124
  this.re(), this.$emit("resize");
125
125
  }).observe(this.flyweight);
126
126
  } catch (t) {
127
- B(t);
127
+ C(t);
128
128
  }
129
129
  },
130
130
  methods: {
131
131
  trigger(t, e) {
132
- this.lazyrun(() => this.$emit(t, T(e) ? !0 : 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
+ });
133
137
  },
134
138
  cheackflys(t) {
135
139
  if (!this.flys.length)
136
140
  return t && this.task.push(t), !0;
137
141
  },
138
142
  setview(t) {
139
- p([this.cheackflys, (e) => {
143
+ d([this.cheackflys, (e) => {
140
144
  e = e || {};
141
- let l = e.index || v(this.flys, (n, i, s, h) => {
142
- if (i[s] == h)
143
- return n;
145
+ let s = e.index || m(this.flys, (h, i, l, r) => {
146
+ if (i[l] == r)
147
+ return h;
144
148
  }, e.picker, e.id);
145
- T(l) || this.setindex(l);
149
+ H(s) || this.setindex(s);
146
150
  }], this, t);
147
151
  },
148
152
  setindex(t) {
149
- p([this.cheackflys, ({ index: e }) => {
153
+ d([this.cheackflys, ({ index: e }) => {
150
154
  this.$nextTick(() => {
151
- let l = e / this.column >> 0, n = this.fwheight;
152
- (this.flyweight.scrollTop / n >> 0) + this.row - l - 1 > 0 || (this.flyweight.scrollTop = l * 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());
153
157
  });
154
158
  }], this, { index: t });
155
159
  },
156
160
  lazyrun(t, e) {
157
161
  clearTimeout(this.time), this.time = setTimeout(() => {
158
- p(t);
162
+ d(t);
159
163
  }, e || this.lazy);
160
164
  },
161
165
  run(t) {
162
- let e = b(t.target, "scrollTop=>top");
163
- v(
166
+ let e = z(t.target, "scrollTop=>top");
167
+ m(
164
168
  this.flyweights,
165
- (l, n, i, s, h, r, a, o) => {
166
- if (i = l / h >> 0, a = i + s * /* 偏移量, 如果超出顶部 + 1轮,排列到列队后, 否则保持在当前*/
167
- (+(i < r % s) + (r / s >> 0)), o = a * h + l % 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) {
168
172
  this.trigger("onend");
169
173
  return;
170
174
  }
171
- n.index = a, n.top = a * this.fwheight, n.data = this.flys[o];
175
+ h.index = u, h.top = u * this.fwheight, h.data = this.flys[o];
172
176
  },
173
177
  null,
174
178
  this.row,
@@ -185,70 +189,72 @@ const C = {
185
189
  if (!t)
186
190
  return e.length = t;
187
191
  this.count = t;
188
- let l = this.flyweight, n = b(l, "clientHeight=>height,clientWidth=>width");
192
+ let s = this.flyweight, h = z(s, "clientHeight=>height,clientWidth=>width");
189
193
  this.$nextTick(() => {
190
- let i = this.auto === !0, [s, h] = this.offset, r = n.width, a = n.height, o = (N(this.width, r) || r) + s, u = N(this.height, a) + h;
191
- this.realW = o - s, this.realH = u - h;
192
- let f = r / o >> 0 || 1, g = a / u >> 0;
193
- this.row = g + 2, this.column = f, this.fwheight = u;
194
- let _ = r % o / (f - 1 * +!i) >> 0;
195
- i && (o = this.realW = (r / f >> 0) - s, _ = s), this.Height = Math.ceil(t / f) * u;
196
- let d = Math.min(t, f * this.row), y = d - 1, c, k;
197
- for (; d-- > 0; )
198
- c = y - d, k = this.flys[c], l = e[c], g = c / f >> 0, this.$set(e, c, {
199
- data: k,
200
- top: g * u,
201
- left: c % f * (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),
202
206
  index: g
203
207
  });
204
- e.length = y + 1, a / u > y && this.trigger("onend"), this.scroll(), this.trigger("update:space", { row: (y / f >> 0) + 1, column: f });
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);
205
211
  });
206
212
  }
207
213
  }
208
- }, I = ["data"];
209
- function j(t, e, l, n, i, s) {
210
- return w(), m("div", {
214
+ }, j = ["data"];
215
+ function M(t, e, s, h, i, l) {
216
+ return x(), _("div", {
211
217
  ref: "flyweight",
212
- class: $(["flyweight", {
218
+ class: O(["flyweight", {
213
219
  "flyweight-active": i.actice
214
220
  }]),
215
- style: x({
221
+ style: b({
216
222
  "--width": i.realW + "px",
217
223
  "--height": i.realH + "px"
218
224
  }),
219
- onScroll: e[0] || (e[0] = (...h) => s.scroll && s.scroll(...h))
225
+ onScroll: e[0] || (e[0] = (...r) => l.scroll && l.scroll(...r))
220
226
  }, [
221
- F("div", {
227
+ L("div", {
222
228
  class: "flyweight-all",
223
- style: x({
229
+ style: b({
224
230
  "--flyweight-height": i.Height + "px"
225
231
  })
226
232
  }, [
227
- (w(!0), m(O, null, L(i.flyweights, (h, r) => (w(), m("div", {
228
- key: r,
229
- data: h.top,
230
- style: x({
231
- top: h.top + "px",
232
- 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"
233
239
  })
234
240
  }, [
235
- z(t.$slots, "default", {
236
- data: h.data,
237
- index: h.index
241
+ T(t.$slots, "default", {
242
+ data: r.data,
243
+ index: r.index
238
244
  }, void 0, !0)
239
- ], 12, I))), 128))
245
+ ], 12, j))), 128))
240
246
  ], 4),
241
- i.flyweights.length ? z(t.$slots, "end", { key: 0 }, void 0, !0) : W("", !0)
247
+ i.flyweights.length ? T(t.$slots, "end", { key: 0 }, void 0, !0) : S("", !0)
242
248
  ], 38);
243
249
  }
244
- const A = /* @__PURE__ */ E(C, [["render", j], ["__scopeId", "data-v-84a26ea4"]]), M = [A], U = {
250
+ const R = /* @__PURE__ */ A(I, [["render", M], ["__scopeId", "data-v-1342d2cb"]]), V = [R], q = {
245
251
  install(t) {
246
- M.forEach((e) => {
252
+ V.forEach((e) => {
247
253
  t.component("s-" + e.name.toLowerCase(), e);
248
254
  });
249
255
  }
250
256
  };
251
257
  export {
252
- A as Flyweight,
253
- U as default
258
+ R as Flyweight,
259
+ q as default
254
260
  };
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .flyweight[data-v-84a26ea4]{height:100%;width:100%;overflow:auto;position:relative}.flyweight .flyweight-all[data-v-84a26ea4]{height:var(--flyweight-height)}.flyweight .flyweight-all[data-v-84a26ea4]>*{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.8",
5
+ "version": "0.0.10",
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
  }
@@ -176,7 +176,12 @@ export default {
176
176
  },
177
177
  methods: {
178
178
  trigger(key, data) {
179
- this.lazyrun(() => this.$emit(key, isNil(data) ? true : 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
+ });
180
185
  },
181
186
  cheackflys(data) {
182
187
  let length = this.flys.length;
@@ -291,10 +296,13 @@ export default {
291
296
  })
292
297
  }
293
298
  fws.length = length + 1;
294
- if (H / height > length) this.trigger('onend');
299
+ let triggers = [];
300
+ if (H / height > length) triggers.push(['onend']);
295
301
  this.scroll();
296
302
  /* 计算占用空间 */
297
- this.trigger('update:space', { row: (length / column >> 0) + 1, column: column });
303
+ triggers.push(['update:space', { row: (length / column >> 0) + 1, column: column }]);
304
+
305
+ this.trigger(triggers);
298
306
  });
299
307
  }
300
308
  }