@kizmann/pico-js 1.0.7 → 1.0.8

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.7",
3
+ "version": "1.0.8",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "private": false,
@@ -133,6 +133,27 @@ export class Dom
133
133
  return this.get(0) && this.get(0).is(':visible');
134
134
  }
135
135
 
136
+ inviewHeight()
137
+ {
138
+ let viewport = {
139
+ width: Dom.find(window).width(),
140
+ height: Dom.find(window).height(),
141
+ };
142
+
143
+ let element = {
144
+ width: this.width(),
145
+ height: this.height(),
146
+ };
147
+
148
+ let scroll = this.scroll(),
149
+ offset = this.offset();
150
+
151
+ let bottom = offset.top + element.height;
152
+
153
+ return Math.max(0, Math.min(bottom, viewport.height + scroll.top) -
154
+ Math.max(offset.top, scroll.top))
155
+ }
156
+
136
157
  inviewX(ratio = 0)
137
158
  {
138
159
  let viewport = {
@@ -181,6 +202,27 @@ export class Dom
181
202
  return top <= scroll.top && scroll.top <= bottom;
182
203
  }
183
204
 
205
+ static inviewMaxY(selector, cb = null)
206
+ {
207
+ let items = [];
208
+
209
+ Dom.find(selector).each((el) => {
210
+ items.push({ el, height: Dom.find(el).inviewHeight() });
211
+ });
212
+
213
+ let heights = Arr.extract(items, 'height');
214
+
215
+ let el = Arr.find(items, (item) => {
216
+ return item.height === Math.max(...heights);
217
+ });
218
+
219
+ if ( ! Any.isEmpty(el) && Any.isFunction(cb) ) {
220
+ cb.call({}, el.el);
221
+ }
222
+
223
+ return el.el;
224
+ }
225
+
184
226
  is(selector)
185
227
  {
186
228
  return this.matches(selector);