-
Notifications
You must be signed in to change notification settings - Fork 0
/
windowevents.js
656 lines (564 loc) · 64.5 KB
/
windowevents.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.WindowEvents = factory());
}(this, (function () { 'use strict';
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
if (i % 2) {
ownKeys(Object(source), true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(Object(source)).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
}
return target;
}
/**
* @author Dave Devor <[email protected]>
*/
/**
* Constuctor to create an object to hold all of the apps covenants.
* @type {Function}
*/
function Covenant() {
/**
* Checks if a variable is a function
* @param {Function} fn
*
* @returns {Boolean}
*/
function isFn(fn) {
return Object.prototype.toString.call(fn) === '[object Function]';
}
/**
* Store incrementing ID for each passed callback
* @type {Int}
*/
var callbackId = 0;
/**
* Store all of our covenants
* @type {Array}
*/
var covenants = [];
/**
* Register an event, or add to an existing event
* @param {String} name Name of the event like: 'loaded'
* @param {Function} fn The closure to execute when signaled.
* @return {Mixed} Unique ID for listener or false on incorrect parameters
*/
this.on = function on() {
var name = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
var fn = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; // Make sure the fn is a function
if (name && fn && isFn(fn)) {
var _exists = false;
var cbObj = {
id: 'cov_' + ++callbackId,
fn: fn
}; // check if this even exists
covenants.forEach(function (cov) {
// If it already exists, add the function to its functions.
if (cov.name === name) {
cov.callbacks.push(cbObj);
_exists = true;
return;
}
}); // If it doesnt exist create it.
if (!_exists) {
var newCovenant = {
name: name,
callbacks: [cbObj]
};
covenants.push(newCovenant);
}
return cbObj.id;
}
return false;
};
/**
* Register an event to fire only once
* @param {String} name Name of the event like: 'loaded'
* @param {Function} fn The closure to execute when signaled.
* @return {Mixed} Unique ID for listener or false on incorrect parameters
*/
this.once = function once() {
var name = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
var fn = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
if (name && fn && isFn(fn)) {
var newId = 'cov_' + (callbackId + 1);
var oneTimeFunc = function () {
fn.apply(null, arguments);
this.off(name, newId);
}.bind(this);
this.on(name, oneTimeFunc);
return newId;
}
return false;
};
/**
* Signal an event and run all of its subscribed functions.
* @param {String} name Name of the event like: 'loaded';
* @param {object[]} args Any arguments that need to be sent to the fn
* @return {object} Current instance of Cov, to allow for chaining
*/
this.signal = function signal() {
var name = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
var args = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];
if (name) {
covenants.forEach(function (cov) {
if (cov.name === name) {
cov.callbacks.forEach(function (cbObj) {
cbObj.fn.apply(null, args);
});
return;
}
});
}
return this;
};
/**
* Unregister (turn off) an event.
* @param {String} Name of the event like: 'loaded';
* @param {String|Function} ID of listener as returned by `on` function, or the original function
* @return {object} Current instance of Cov, to allow for chaining
*/
this.off = function off() {
var name = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
var id = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1];
if (name) {
covenants.forEach(function (cov, index, arr) {
if (cov.name === name) {
// If no ID is passed, remove all listeners
if (!id) {
arr.splice(index, 1);
} else {
// Otherwise just remove specified callback
cov.callbacks.forEach(function (cbObj, ix, callbacks) {
// Remove based off ID or the reference of the function passed matches original
if (cbObj.id === id || isFn(id) && cbObj.fn === id) {
callbacks.splice(ix, 1);
}
});
}
return;
}
});
}
return this;
};
}
var cov = new Covenant();
var cov_1 = {
cov: cov,
Covenant: Covenant
};
/* eslint-disable no-undefined,no-param-reassign,no-shadow */
/**
* Throttle execution of a function. Especially useful for rate limiting
* execution of handlers on events like resize and scroll.
*
* @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
* @param {Boolean} [noTrailing] Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the
* throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time
* after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,
* the internal counter is reset)
* @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
* to `callback` when the throttled-function is executed.
* @param {Boolean} [debounceMode] If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),
* schedule `callback` to execute after `delay` ms.
*
* @return {Function} A new, throttled, function.
*/
var throttle = function throttle(delay, noTrailing, callback, debounceMode) {
// After wrapper has stopped being called, this timeout ensures that
// `callback` is executed at the proper times in `throttle` and `end`
// debounce modes.
var timeoutID; // Keep track of the last time `callback` was executed.
var lastExec = 0; // `noTrailing` defaults to falsy.
if (typeof noTrailing !== 'boolean') {
debounceMode = callback;
callback = noTrailing;
noTrailing = undefined;
} // The `wrapper` function encapsulates all of the throttling / debouncing
// functionality and when executed will limit the rate at which `callback`
// is executed.
function wrapper() {
var self = this;
var elapsed = Number(new Date()) - lastExec;
var args = arguments; // Execute `callback` and update the `lastExec` timestamp.
function exec() {
lastExec = Number(new Date());
callback.apply(self, args);
} // If `debounceMode` is true (at begin) this is used to clear the flag
// to allow future `callback` executions.
function clear() {
timeoutID = undefined;
}
if (debounceMode && !timeoutID) {
// Since `wrapper` is being called for the first time and
// `debounceMode` is true (at begin), execute `callback`.
exec();
} // Clear any existing timeout.
if (timeoutID) {
clearTimeout(timeoutID);
}
if (debounceMode === undefined && elapsed > delay) {
// In throttle mode, if `delay` time has been exceeded, execute
// `callback`.
exec();
} else if (noTrailing !== true) {
// In trailing throttle mode, since `delay` time has not been
// exceeded, schedule `callback` to execute `delay` ms after most
// recent execution.
//
// If `debounceMode` is true (at begin), schedule `clear` to execute
// after `delay` ms.
//
// If `debounceMode` is false (at end), schedule `callback` to
// execute after `delay` ms.
timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);
}
} // Return the wrapper function.
return wrapper;
};
/* eslint-disable no-undefined */
/**
* Debounce execution of a function. Debouncing, unlike throttling,
* guarantees that a function is only executed a single time, either at the
* very beginning of a series of calls, or at the very end.
*
* @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
* @param {Boolean} [atBegin] Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds
* after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.
* (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).
* @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
* to `callback` when the debounced-function is executed.
*
* @return {Function} A new, debounced function.
*/
var debounce = function debounce(delay, atBegin, callback) {
return callback === undefined ? throttle(delay, atBegin, false) : throttle(delay, callback, atBegin !== false);
};
var ScrollEvents = /*#__PURE__*/function () {
function ScrollEvents(publisher, options, sizeRef) {
_classCallCheck(this, ScrollEvents);
this.signal = publisher.signal;
this.options = options;
this.windowSize = sizeRef;
this.scrollTimeout = null;
this.debouncedListener = this.debouncedListener.bind(this);
this.throttledListener = this.throttledListener.bind(this);
this.updateState();
}
_createClass(ScrollEvents, [{
key: "updateState",
value: function updateState() {
this.scrollTop = this.lastScrollTop = window.scrollY || window.pageYOffset;
this.scrollPercent = this.scrollTop / (this.windowSize.scrollHeight - this.windowSize.height) * 100;
}
}, {
key: "getState",
value: function getState() {
return {
scrollTop: this.scrollTop,
scrollPercent: this.scrollPercent
};
}
}, {
key: "debouncedListener",
value: function debouncedListener() {
this.scrollTop = window.scrollY || window.pageYOffset;
this.scrollPercent = this.scrollTop / (this.windowSize.scrollHeight - this.windowSize.height) * 100;
this.signal('scroll.start', [{
scrollTop: this.scrollTop,
scrollPercent: this.scrollPercent
}]);
this.lastScrollTop = this.scrollTop;
}
}, {
key: "throttledListener",
value: function throttledListener() {
var _this = this;
this.scrollTop = window.scrollY || window.pageYOffset;
this.scrollPercent = this.scrollTop / (this.windowSize.scrollHeight - this.windowSize.height) * 100;
var scrollObj = {
scrollTop: this.scrollTop,
scrollPercent: this.scrollPercent
};
this.signal('scroll', [scrollObj]);
if (this.scrollTop > this.lastScrollTop) {
this.signal('scroll.down', [scrollObj]);
} else if (this.scrollTop < this.lastScrollTop) {
this.signal('scroll.up', [scrollObj]);
}
if (this.scrollTop <= 0) {
this.signal('scroll.top', [scrollObj]);
}
if (scrollObj.scrollPercent >= 100) {
this.signal('scroll.bottom', [scrollObj]);
}
clearTimeout(this.scrollTimeout);
this.scrollTimeout = setTimeout(function () {
_this.signal('scroll.stop', [scrollObj]);
}, this.options.scrollDelay + 1);
this.lastScrollTop = this.scrollTop;
}
}]);
return ScrollEvents;
}();
var ResizeEvents = /*#__PURE__*/function () {
function ResizeEvents(publisher, options) {
_classCallCheck(this, ResizeEvents);
this.signal = publisher.signal;
this.options = options;
this.resizeTimeout = null;
this.debouncedListener = this.debouncedListener.bind(this);
this.throttledListener = this.throttledListener.bind(this);
this.updateState();
}
_createClass(ResizeEvents, [{
key: "updateState",
value: function updateState() {
this.height = this.lastH = window.innerHeight;
this.width = this.lastW = window.innerWidth;
this.scrollHeight = this.lastS = document.body.scrollHeight;
this.orientation = this.lastO = this.height > this.width ? 'portrait' : 'landscape';
}
}, {
key: "getState",
value: function getState() {
return {
height: this.height,
width: this.width,
scrollHeight: this.scrollHeight,
orientation: this.orientation
};
}
}, {
key: "debouncedListener",
value: function debouncedListener() {
this.height = window.innerHeight;
this.width = window.innerWidth;
this.scrollHeight = document.body.scrollHeight;
this.orientation = this.height > this.width ? 'portrait' : 'landscape';
var sizeObj = {
height: this.height,
width: this.width,
scrollHeight: this.scrollHeight,
orientation: this.orientation
};
this.signal('resize.start', [sizeObj]);
this.lastH = this.height;
this.lastW = this.width;
this.lastS = this.scrollHeight;
}
}, {
key: "throttledListener",
value: function throttledListener() {
var _this = this;
this.height = window.innerHeight;
this.width = window.innerWidth;
this.scrollHeight = document.body.scrollHeight;
this.orientation = this.height > this.width ? 'portrait' : 'landscape';
var sizeObj = {
height: this.height,
width: this.width,
scrollHeight: this.scrollHeight,
orientation: this.orientation
};
this.signal('resize', [sizeObj]);
if (this.orientation !== this.lastO) {
this.signal('resize.orientationChange', [sizeObj]);
}
if (this.scrollHeight !== this.lastS) {
this.signal('resize.scrollHeightChange', [sizeObj]);
}
clearTimeout(this.scrollTimeout);
this.scrollTimeout = setTimeout(function () {
_this.signal('resize.stop', [sizeObj]);
}, this.options.resizeDelay + 1);
this.lastH = this.height;
this.lastW = this.width;
this.lastS = this.scrollHeight;
this.lastO = this.orientation;
}
}]);
return ResizeEvents;
}();
var VisibilityEvents = /*#__PURE__*/function () {
function VisibilityEvents(publisher, options) {
_classCallCheck(this, VisibilityEvents);
this.signal = publisher.signal;
this.options = options;
this.changeListenter = this.changeListenter.bind(this);
this.updateState();
}
_createClass(VisibilityEvents, [{
key: "updateState",
value: function updateState() {
this.visible = !document.hidden;
}
}, {
key: "getState",
value: function getState() {
return {
visible: this.visible
};
}
}, {
key: "changeListenter",
value: function changeListenter() {
this.visible = !document.hidden;
var visibleObj = {
visible: this.visible
};
this.signal('visibilityChange', [visibleObj]);
if (this.visible) {
this.signal('visibilityChange.show', [visibleObj]);
} else {
this.signal('visibilityChange.hide', [visibleObj]);
}
}
}]);
return VisibilityEvents;
}();
var LoadEvents = /*#__PURE__*/function () {
function LoadEvents(publisher, options) {
_classCallCheck(this, LoadEvents);
this.signal = publisher.signal;
this.options = options;
this.changeListenter = this.changeListenter.bind(this);
this.updateState();
}
_createClass(LoadEvents, [{
key: "updateState",
value: function updateState() {
this.loaded = document.readyState;
}
}, {
key: "getState",
value: function getState() {
return {
loaded: this.loaded
};
}
}, {
key: "changeListenter",
value: function changeListenter() {
this.loaded = document.readyState;
var loadedObj = {
loaded: this.loaded
};
this.signal('load', [loadedObj]);
if (this.loaded === 'interactive') {
this.signal('load.interactive', [loadedObj]);
} else if (this.loaded === 'complete') {
this.signal('load.complete', [loadedObj]);
}
}
}]);
return LoadEvents;
}();
var WindowEvents = function WindowEvents(opts) {
var _this = this;
_classCallCheck(this, WindowEvents);
var defaultOptions = {
scrollDelay: 100,
resizeDelay: 350
};
this.options = opts ? _objectSpread2(_objectSpread2({}, defaultOptions), opts) : defaultOptions;
var publisher = new cov_1.Covenant();
this.on = publisher.on;
this.once = publisher.once;
this.off = publisher.off;
var resizeEvents = new ResizeEvents(publisher, this.options); // Pass resizeEvents object to scroll listener
// in order to have access to window height, width
var scrollEvents = new ScrollEvents(publisher, this.options, resizeEvents);
var visibilityEvents = new VisibilityEvents(publisher, this.options);
var loadEvents = new LoadEvents(publisher, this.options);
this.getState = function () {
return _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, resizeEvents.getState()), scrollEvents.getState()), visibilityEvents.getState()), loadEvents.getState());
};
this.updateState = function () {
resizeEvents.updateState();
scrollEvents.updateState();
visibilityEvents.updateState();
loadEvents.updateState();
return _this.getState();
};
window.addEventListener('scroll', debounce( // Delay
this.options.scrollDelay, // At beginning
true, // Debounced function
scrollEvents.debouncedListener), false);
window.addEventListener('scroll', throttle( // Delay
this.options.scrollDelay, // No Trailing. If false, will get called one last time after the last throttled call
false, // Throttled function
scrollEvents.throttledListener), false);
window.addEventListener('resize', debounce( // Delay
this.options.resizeDelay, // At beginning
true, // Debounced function
resizeEvents.debouncedListener), false);
window.addEventListener('resize', throttle( // Delay
this.options.resizeDelay, // No Trailing. If false, will get called one last time after the last throttled call
false, // Throttled function
resizeEvents.throttledListener), false);
window.addEventListener('visibilitychange', visibilityEvents.changeListenter, false);
document.addEventListener('readystatechange', function () {
// Update the state once all
// images and resources have loaded
_this.updateState();
loadEvents.changeListenter();
}, false);
};
return WindowEvents;
})));
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2luZG93ZXZlbnRzLmpzIiwic291cmNlcyI6WyJub2RlX21vZHVsZXMvY292anMvY292LmpzIiwibm9kZV9tb2R1bGVzL3Rocm90dGxlLWRlYm91bmNlL3Rocm90dGxlLmpzIiwibm9kZV9tb2R1bGVzL3Rocm90dGxlLWRlYm91bmNlL2RlYm91bmNlLmpzIiwic3JjL3Njcm9sbC5qcy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