@playpilot/tpi 6.4.0-beta.1 → 6.4.0-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playpilot/tpi",
3
- "version": "6.4.0-beta.1",
3
+ "version": "6.4.0-beta.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -4,9 +4,4 @@ export const SplitTest = {
4
4
  numberOfVariants: 2,
5
5
  variantNames: ['Separated', 'Inline'] as string[],
6
6
  },
7
- PostersScrollReveal: {
8
- key: 'posters_scroll_reveal',
9
- numberOfVariants: 2,
10
- variantNames: ['Default', 'With Posters'] as string[],
11
- },
12
7
  } as const
@@ -102,8 +102,7 @@ h1, h2, h3, h4, h5 {
102
102
 
103
103
  @keyframes playpilot-poster-fly-in {
104
104
  from {
105
- opacity: 0;
106
- transform: translateX(-50%) translateY(1.5rem);
105
+ transform: translateX(-50%) translateY(1.5rem) rotateX(90deg);
107
106
  }
108
107
  }
109
108
 
@@ -127,7 +126,7 @@ h1, h2, h3, h4, h5 {
127
126
  transform-origin: bottom center;
128
127
 
129
128
  &.loaded {
130
- animation: playpilot-poster-fly-in 500ms cubic-bezier(0.25, 1.75, 0.5, 1);
129
+ animation: playpilot-poster-fly-in 600ms cubic-bezier(0.35, 1.75, 0.75, 1);
131
130
  opacity: 1;
132
131
  }
133
132
 
@@ -1,45 +1,18 @@
1
1
  <script lang="ts">
2
- import { mobileBreakpoint } from '$lib/constants'
3
- import { SplitTest } from '$lib/enums/SplitTest'
4
- import { isInSplitTestVariant, trackSplitTestAction, trackSplitTestView } from '$lib/splitTest'
5
2
  import { onMount } from 'svelte'
6
3
 
7
4
  const linksWithPosters = Array.from(document.querySelectorAll<HTMLElement>('[data-playpilot-poster-url]'))
8
5
  const linksWithCurrentlyVisiblePosters = new Set<HTMLElement>()
9
- const targetThreshold = 0.6
6
+ const targetThreshold = 0.7
10
7
  const posterSelector = '[data-playpilot-poster]'
11
8
 
12
- let windowWidth = $state(0)
13
9
  let scrollTimeout: ReturnType<typeof setTimeout> | null = null
14
10
 
15
- const isMobile = $derived(windowWidth < mobileBreakpoint)
16
-
17
11
  onMount(() => {
18
- if (!isMobile) return
19
-
20
- trackSplitTestView(SplitTest.PostersScrollReveal)
21
-
22
12
  return destroyAllPosters
23
13
  })
24
14
 
25
- $effect(() => {
26
- if (!isMobile) return
27
- if (!isInSplitTestVariant(SplitTest.PostersScrollReveal)) return
28
- if (!linksWithPosters.length) return
29
-
30
- const onclick = () => trackSplitTestAction(SplitTest.PostersScrollReveal, 'click')
31
-
32
- for(const link of linksWithPosters) link.addEventListener('click', onclick)
33
-
34
- return () => {
35
- for(const link of linksWithPosters) link.removeEventListener('click', onclick)
36
- }
37
- })
38
-
39
15
  function onscroll(): void {
40
- if (!isMobile) return
41
- if (!isInSplitTestVariant(SplitTest.PostersScrollReveal)) return
42
-
43
16
  setScrollTimeout()
44
17
 
45
18
  const windowHeight = window.innerHeight
@@ -57,13 +30,6 @@
57
30
  linksWithinTargetViewport.add(link)
58
31
  }
59
32
 
60
- for (const link of linksWithCurrentlyVisiblePosters) {
61
- if (linksWithinTargetViewport.has(link)) continue
62
-
63
- destroyPosterForLink(link)
64
- linksWithCurrentlyVisiblePosters.delete(link)
65
- }
66
-
67
33
  for (const link of linksWithinTargetViewport) {
68
34
  if (linksWithCurrentlyVisiblePosters.has(link)) continue
69
35
 
@@ -113,4 +79,4 @@
113
79
  }
114
80
  </script>
115
81
 
116
- <svelte:window {onscroll} bind:innerWidth={windowWidth} />
82
+ <svelte:window {onscroll} />
@@ -1,14 +1,6 @@
1
- import { fireEvent, render } from '@testing-library/svelte'
1
+ import { render } from '@testing-library/svelte'
2
2
  import { describe, it, expect, vi, beforeEach } from 'vitest'
3
3
  import PostersScrollReveal from '../../../routes/components/PostersScrollReveal.svelte'
4
- import { mobileBreakpoint } from '$lib/constants'
5
- import { isInSplitTestVariant, trackSplitTestAction } from '$lib/splitTest'
6
-
7
- vi.mock('$lib/splitTest', () => ({
8
- trackSplitTestView: vi.fn(),
9
- trackSplitTestAction: vi.fn(),
10
- isInSplitTestVariant: vi.fn(() => true),
11
- }))
12
4
 
13
5
  function createPosterLink(top = 0, url = 'poster.jpg') {
14
6
  const link = document.createElement('a')
@@ -30,15 +22,8 @@ describe('FloatingPoster', () => {
30
22
  writable: true,
31
23
  })
32
24
 
33
- Object.defineProperty(window, 'innerWidth', {
34
- value: mobileBreakpoint - 1,
35
- writable: true,
36
- })
37
-
38
25
  vi.useFakeTimers()
39
26
  vi.resetAllMocks()
40
-
41
- vi.mocked(isInSplitTestVariant).mockReturnValue(true)
42
27
  })
43
28
 
44
29
  it('Should create poster when link is in viewport', async () => {
@@ -53,21 +38,6 @@ describe('FloatingPoster', () => {
53
38
  expect(poster?.getAttribute('src')).toBe('poster.jpg')
54
39
  })
55
40
 
56
- it('Should not create posters on desktop when link is in viewport', async () => {
57
- createPosterLink(500)
58
-
59
- Object.defineProperty(window, 'innerWidth', {
60
- value: mobileBreakpoint + 1,
61
- writable: true,
62
- })
63
-
64
- render(PostersScrollReveal)
65
-
66
- window.dispatchEvent(new Event('scroll'))
67
-
68
- expect(document.querySelector('[data-playpilot-poster]')).not.toBeTruthy()
69
- })
70
-
71
41
  it('Should not create poster when link is below in viewport', async () => {
72
42
  createPosterLink(2000)
73
43
 
@@ -134,16 +104,4 @@ describe('FloatingPoster', () => {
134
104
  window.dispatchEvent(new Event('scroll'))
135
105
  expect(document.querySelector('[data-playpilot-poster]')).toBeTruthy()
136
106
  })
137
-
138
- it('Should fire split test tracking on click', async () => {
139
- createPosterLink(500)
140
-
141
- render(PostersScrollReveal)
142
-
143
- window.dispatchEvent(new Event('scroll'))
144
-
145
- await fireEvent.click(/** @type {HTMLElement} */ (document.querySelector('[data-playpilot-poster]')))
146
-
147
- expect(trackSplitTestAction).toHaveBeenCalled()
148
- })
149
107
  })