@kizmann/pico-js 1.0.8 → 1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizmann/pico-js",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "private": false,
@@ -202,11 +202,19 @@ export class Dom
202
202
  return top <= scroll.top && scroll.top <= bottom;
203
203
  }
204
204
 
205
- static inviewMaxY(selector, cb = null)
205
+ static inviewMaxY(selector, callback = null, context = null)
206
206
  {
207
- let items = [];
207
+ let [items, attr] = [
208
+ [], selector.replace(/^\[([^="]+)]$/, '$1')
209
+ ];
208
210
 
209
- Dom.find(selector).each((el) => {
211
+ let parent = Dom.find(selector);
212
+
213
+ if ( ! Any.isNull(context) ) {
214
+ parent = Dom.find(context);
215
+ }
216
+
217
+ parent.each((el) => {
210
218
  items.push({ el, height: Dom.find(el).inviewHeight() });
211
219
  });
212
220
 
@@ -216,8 +224,8 @@ export class Dom
216
224
  return item.height === Math.max(...heights);
217
225
  });
218
226
 
219
- if ( ! Any.isEmpty(el) && Any.isFunction(cb) ) {
220
- cb.call({}, el.el);
227
+ if ( ! Any.isEmpty(el) && Any.isFunction(callback) ) {
228
+ callback.call({}, el.el, el.el.getAttribute(attr));
221
229
  }
222
230
 
223
231
  return el.el;