@rokkit/helpers 1.0.0-next.127 → 1.0.0-next.129

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.
@@ -0,0 +1,10 @@
1
+ export class IntersectionObserver {
2
+ constructor(callback: any, options?: {});
3
+ callback: any;
4
+ options: {};
5
+ elements: Set<any>;
6
+ observe(element: any): void;
7
+ unobserve(element: any): void;
8
+ disconnect(): void;
9
+ simulateIntersection(entries: any): void;
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/helpers",
3
- "version": "1.0.0-next.127",
3
+ "version": "1.0.0-next.129",
4
4
  "description": "Custom matchers for vitest, mocks and simulators for testing.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -1,5 +1,6 @@
1
1
  import './animate'
2
2
  import { ResizeObserver } from './resize-observer'
3
+ import { IntersectionObserver } from './intersection-observer'
3
4
 
4
5
  // skipcq: JS-E1004 - Needed for exposing all functions
5
6
  export * from './match-media'
@@ -7,3 +8,10 @@ export * from './match-media'
7
8
  export * from './element'
8
9
 
9
10
  global.ResizeObserver = ResizeObserver
11
+ global.IntersectionObserver = IntersectionObserver
12
+
13
+ // JSDOM doesn't implement document.execCommand (used by Code.svelte clipboard)
14
+ if (typeof document !== 'undefined' && !document.execCommand) {
15
+ document.execCommand = () => false
16
+ }
17
+
@@ -0,0 +1,24 @@
1
+ export class IntersectionObserver {
2
+ constructor(callback, options = {}) {
3
+ this.callback = callback
4
+ this.options = options
5
+ this.elements = new Set()
6
+ }
7
+
8
+ observe(element) {
9
+ this.elements.add(element)
10
+ }
11
+
12
+ unobserve(element) {
13
+ this.elements.delete(element)
14
+ }
15
+
16
+ disconnect() {
17
+ this.elements.clear()
18
+ }
19
+
20
+ // Simulate entries becoming visible
21
+ simulateIntersection(entries) {
22
+ this.callback(entries, this)
23
+ }
24
+ }