powered-ad-config 0.0.85 → 0.0.86

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/README.md CHANGED
@@ -104,7 +104,7 @@ const cleanup = initAd({
104
104
 
105
105
  | Option | Type | Default | Used by | Description |
106
106
  |---|---|---:|---|---|
107
- | `adFormat` | `string` | `''` | all | Format selector. Supported: `fireplace`, `fireplace-collant`, `logomorph` |
107
+ | `adFormat` | `string` | `''` | all | Format selector. Supported: `fireplace`, `fireplace-collant`, `logomorph`, `interscroller` |
108
108
  | `stickyOffset` | `number` | `0` | fireplace, fireplace-collant | Extra offset added to sticky/scroll threshold calculations |
109
109
  | `logoPosX` | `number` | `0` | logomorph | Scroll threshold where logo transitions to small state |
110
110
  | `logoHeight` | `number` | `0` | logomorph | Height (px) for large logo state |
@@ -119,6 +119,127 @@ const cleanup = initAd({
119
119
  - `fireplace`: Billboard/fireplace behavior with sticky scroll transforms.
120
120
  - `fireplace-collant`: Fireplace behavior with collant transition and content masking.
121
121
  - `logomorph`: Large-to-small logo takeover behavior on scroll.
122
+ - `interscroller`: Full-viewport scroll-through ad with sticky bands, GSAP stretch animation, and scroll progress callbacks.
123
+
124
+ ---
125
+
126
+ ## Interscroller
127
+
128
+ Expands the ad container to a configurable scroll height (e.g. `300vh`) and locks a full-viewport-width creative iframe behind the page content using `clip-path`. As the user scrolls, the ad reveals and the top/bottom bands animate accordingly.
129
+
130
+ ### Quick start
131
+
132
+ ```js
133
+ import initAd from 'powered-ad-config';
134
+
135
+ initAd({
136
+ adFormat: 'interscroller',
137
+
138
+ // optional overrides (see CONFIG table below)
139
+ adScrollHeight: '200vh',
140
+ onProgress({ scrollProgress, adExposure, viewportCoverage, pxRemaining }) {
141
+ gsap.set(myElement, { y: scrollProgress * -100 });
142
+ },
143
+ thresholds: [
144
+ { at: 0.2, onEnter: () => playVideo(), onLeave: () => pauseVideo() },
145
+ ],
146
+ });
147
+ ```
148
+
149
+ ### CONFIG options
150
+
151
+ All options are optional. The defaults are shown below.
152
+
153
+ #### Ad scroll zone
154
+
155
+ | Option | Type | Default | Description |
156
+ |---|---|---|---|
157
+ | `adScrollHeight` | `string` | `'300vh'` | CSS height of the ad container. Controls how long the ad stays in view. `100vh` = standard; `200vh` = twice as long. Accepts any CSS length (`'150vh'`, `'600px'`, etc.). |
158
+
159
+ #### Bands
160
+
161
+ | Option | Type | Default | Description |
162
+ |---|---|---|---|
163
+ | `bandHeight` | `number` | `24` | Height in px of both the top and bottom bands. |
164
+ | `bandBg` | `string` | `'#222'` | Band background colour. |
165
+ | `bandColor` | `string` | `'#fff'` | Band text colour. |
166
+ | `bandFontSize` | `string` | `'10px'` | Band font size. |
167
+ | `bandFontFamily` | `string` | `'Arial, Helvetica, sans-serif'` | Band font family. |
168
+ | `bandLetterSpacing` | `string` | `'1px'` | Band letter spacing. |
169
+ | `labelTop` | `string` | `'Advertisement'` | Text shown in the top band. |
170
+ | `labelBottomResume` | `string` | `'Content resumes in {n}px'` | Bottom band text while scrolling through the ad. `{n}` is replaced with the live pixel count. |
171
+ | `labelBottomNow` | `string` | `'Content resumes now ↓'` | Bottom band text once the post-ad content enters the viewport. |
172
+ | `zIndexTop` | `number` | `9` | `z-index` of the top band (keep below the page header). |
173
+ | `zIndexBottom` | `number` | `8` | `z-index` of the bottom band. |
174
+
175
+ #### Stretch animation
176
+
177
+ The top band stretches downward as the two bands approach each other, then snaps back with an elastic ease.
178
+
179
+ | Option | Type | Default | Description |
180
+ |---|---|---|---|
181
+ | `snapPx` | `number` | `30` | Gap in px between the bands at which the elastic snap fires. |
182
+ | `snapOverlap` | `number` | `2` | Fires the snap this many px before `snapPx` is reached (trigger timing adjustment). |
183
+ | `stretchOverlap` | `number` | `2` | Starts the stretch this many px before the bands touch, and extends the band this many px past the touchpoint — eliminates the sub-pixel rendering gap. |
184
+ | `snapDuration` | `number` | `0.9` | Duration in seconds of the elastic return animation. |
185
+ | `snapEase` | `string` | `'cubic-bezier(0.175, 0.885, 0.32, 1.275)'` | CSS timing function for the snap. Any valid CSS `transition-timing-function` value works. |
186
+
187
+ ### Scroll callbacks
188
+
189
+ #### `onEnter()` · `onExit()`
190
+
191
+ Lifecycle callbacks fired once per ad pass.
192
+
193
+ ```js
194
+ onEnter() {
195
+ // ad top band just entered the viewport — start intro animation
196
+ },
197
+ onExit() {
198
+ // post-ad content entered — pause video, clean up, etc.
199
+ },
200
+ ```
201
+
202
+ #### `onProgress(state)`
203
+
204
+ Fired on every scroll event while the page is within range of the ad.
205
+
206
+ ```js
207
+ onProgress({ scrollProgress, adExposure, viewportCoverage, pxRemaining }) {
208
+ // drive your scroll-synced animation here
209
+ }
210
+ ```
211
+
212
+ | Property | Range | Description |
213
+ |---|---|---|
214
+ | `scrollProgress` | `0 → 1` | Overall position through the full scroll zone. `0` = ad top enters viewport, `1` = ad bottom exits. |
215
+ | `adExposure` | `0 → 1` | Fraction of the ad's total height (`adScrollHeight`) that has scrolled into view. Useful for a multi-screen creative (e.g. a 300vh mini-page) — at `0.33`, one-third of the creative has been seen. |
216
+ | `viewportCoverage` | `0 → 1` | Fraction of the screen currently filled by the ad. Useful for parallax, opacity, or scale effects tied to how "dominant" the ad is on screen. |
217
+ | `pxRemaining` | `≥ 0` | Pixels left to scroll until the ad clears the bottom band. Same value shown in the bottom band counter. |
218
+
219
+ #### `thresholds`
220
+
221
+ An array of trigger points keyed to `scrollProgress`. Each fires `onEnter` when scrolling forward past `at`, and `onLeave` when scrolling back — direction-aware, so rubber-banding and reverse scrolling work correctly.
222
+
223
+ ```js
224
+ thresholds: [
225
+ {
226
+ at: 0.2, // fires when scrollProgress crosses 20%
227
+ onEnter: (progress) => playVideo(),
228
+ onLeave: (progress) => pauseVideo(),
229
+ },
230
+ {
231
+ at: 0.5,
232
+ onEnter: () => triggerSecondAnimation(),
233
+ // onLeave is optional
234
+ },
235
+ ],
236
+ ```
237
+
238
+ | Property | Type | Description |
239
+ |---|---|---|
240
+ | `at` | `number` (0–1) | `scrollProgress` value at which to cross. |
241
+ | `onEnter` | `function(progress)` | Called when scrolling forward past `at`. |
242
+ | `onLeave` | `function(progress)` | Called when scrolling back below `at`. Optional. |
122
243
 
123
244
  ## Integration Notes
124
245