@kizmann/pico-js 1.0.6 → 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.6",
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);
@@ -903,6 +945,17 @@ export class Dom
903
945
  return this;
904
946
  }
905
947
 
948
+ stateClass(vals, state = true)
949
+ {
950
+ if ( this.length() > 1 ) {
951
+ return this.each((el) => Dom.find(el).stateClass(vals, state));
952
+ }
953
+
954
+ state ? this.addClass(vals) : this.removeClass(vals);
955
+
956
+ return this;
957
+ }
958
+
906
959
  attr(attr, val = undefined)
907
960
  {
908
961
  if ( this.empty() ) {
@@ -101,8 +101,9 @@ export class Num
101
101
  value = Any.float(num).toFixed(fixed);
102
102
  }
103
103
 
104
- let totals = value.replace(/\.[0-9]+$/, ''),
105
- minals = value.replace(/^[0-9\-]+\./, '');
104
+ let [totals, minals] = [
105
+ value.replace(/\.[0-9]+$/, ''), value.replace(/^[0-9\-]+\./, '')
106
+ ];
106
107
 
107
108
  let splits = Arr.reduce(totals.split('').reverse(), (result, val, key) => {
108
109