@html-next/vertical-collection 5.0.2 → 5.0.3

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.
@@ -1,80 +0,0 @@
1
- /*
2
- * There are significant differences between browsers
3
- * in how they implement "scroll" on document.body
4
- *
5
- * The only cross-browser listener for scroll on body
6
- * is to listen on window with capture.
7
- *
8
- * They also implement different standards for how to
9
- * access the scroll position.
10
- *
11
- * This singleton class provides a cross-browser way
12
- * to access and set the scrollTop and scrollLeft properties.
13
- *
14
- */
15
- export function ViewportContainer() {
16
- // A bug occurs in Chrome when we reload the browser at a lower
17
- // scrollTop, window.scrollY becomes stuck on a single value.
18
- Object.defineProperty(this, 'scrollTop', {
19
- get() {
20
- return document.body.scrollTop || document.documentElement.scrollTop;
21
- },
22
- set(v) {
23
- document.body.scrollTop = document.documentElement.scrollTop = v;
24
- },
25
- });
26
-
27
- Object.defineProperty(this, 'scrollLeft', {
28
- get() {
29
- return (
30
- window.scrollX ||
31
- window.pageXOffset ||
32
- document.body.scrollLeft ||
33
- document.documentElement.scrollLeft
34
- );
35
- },
36
- set(v) {
37
- window.scrollX =
38
- window.pageXOffset =
39
- document.body.scrollLeft =
40
- document.documentElement.scrollLeft =
41
- v;
42
- },
43
- });
44
-
45
- Object.defineProperty(this, 'offsetHeight', {
46
- get() {
47
- return window.innerHeight;
48
- },
49
- });
50
- }
51
-
52
- ViewportContainer.prototype.addEventListener = function addEventListener(
53
- event,
54
- handler,
55
- options,
56
- ) {
57
- return window.addEventListener(event, handler, options);
58
- };
59
-
60
- ViewportContainer.prototype.removeEventListener = function addEventListener(
61
- event,
62
- handler,
63
- options,
64
- ) {
65
- return window.removeEventListener(event, handler, options);
66
- };
67
-
68
- ViewportContainer.prototype.getBoundingClientRect =
69
- function getBoundingClientRect() {
70
- return {
71
- height: window.innerHeight,
72
- width: window.innerWidth,
73
- top: 0,
74
- left: 0,
75
- right: window.innerWidth,
76
- bottom: window.innerHeight,
77
- };
78
- };
79
-
80
- export default new ViewportContainer();
@@ -1,16 +0,0 @@
1
- let supportsPassive = false;
2
-
3
- try {
4
- let opts = Object.defineProperty({}, 'passive', {
5
- get() {
6
- supportsPassive = true;
7
- return supportsPassive;
8
- },
9
- });
10
-
11
- window.addEventListener('test', null, opts);
12
- } catch {
13
- // do nothing
14
- }
15
-
16
- export default supportsPassive;
@@ -1,31 +0,0 @@
1
- const VENDOR_MATCH_FNS = [
2
- 'matches',
3
- 'webkitMatchesSelector',
4
- 'mozMatchesSelector',
5
- 'msMatchesSelector',
6
- 'oMatchesSelector',
7
- ];
8
- let ELEMENT_MATCH_FN;
9
-
10
- function setElementMatchFn(el) {
11
- VENDOR_MATCH_FNS.forEach((fn) => {
12
- if (ELEMENT_MATCH_FN === undefined && typeof el[fn] === 'function') {
13
- ELEMENT_MATCH_FN = fn;
14
- }
15
- });
16
- }
17
-
18
- export default function closest(el, selector) {
19
- if (ELEMENT_MATCH_FN === undefined) {
20
- setElementMatchFn(el);
21
- }
22
- while (el) {
23
- // TODO add explicit test
24
- if (el[ELEMENT_MATCH_FN](selector)) {
25
- return el;
26
- }
27
- el = el.parentElement;
28
- }
29
-
30
- return null;
31
- }