@cntrl-site/sdk-nextjs 1.9.13-9 → 1.9.13
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.
|
@@ -110,7 +110,8 @@ class InteractionsRegistry {
|
|
|
110
110
|
const timestamp = Date.now();
|
|
111
111
|
for (const interaction of this.interactions) {
|
|
112
112
|
const currentStateId = this.getCurrentStateByInteractionId(interaction.id);
|
|
113
|
-
const matchingTrigger = interaction.triggers.find(trigger => ('position' in trigger && trigger.position === 0 && trigger.from === currentStateId)
|
|
113
|
+
const matchingTrigger = interaction.triggers.find(trigger => ('position' in trigger && trigger.position === 0 && trigger.from === currentStateId)
|
|
114
|
+
|| (trigger.type === 'item-scroll-position' && this.items.find((item) => item.id === trigger.itemId) && trigger.from === currentStateId));
|
|
114
115
|
if (!matchingTrigger)
|
|
115
116
|
continue;
|
|
116
117
|
const activeStateId = this.getActiveInteractionState(interaction.id);
|
|
@@ -164,8 +165,21 @@ class InteractionsRegistry {
|
|
|
164
165
|
triggerPosition = trigger.position * window.innerWidth;
|
|
165
166
|
}
|
|
166
167
|
if (trigger.type === 'item-scroll-position') {
|
|
167
|
-
const
|
|
168
|
-
|
|
168
|
+
const itemArea = this.items.find((item) => item.id === trigger.itemId).area[this.layoutId];
|
|
169
|
+
switch (trigger.itemPosition) {
|
|
170
|
+
case 'top':
|
|
171
|
+
triggerPosition = itemArea.top * window.innerWidth;
|
|
172
|
+
break;
|
|
173
|
+
case 'center':
|
|
174
|
+
triggerPosition = itemArea.top * window.innerWidth - window.innerHeight / 2;
|
|
175
|
+
break;
|
|
176
|
+
case 'bottom':
|
|
177
|
+
triggerPosition = itemArea.top * window.innerWidth - window.innerHeight;
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
triggerPosition = itemArea.top * window.innerWidth;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
169
183
|
}
|
|
170
184
|
if (!triggerPosition)
|
|
171
185
|
return false;
|
|
@@ -182,8 +196,21 @@ class InteractionsRegistry {
|
|
|
182
196
|
triggerPosition = matchingTrigger.position * window.innerWidth;
|
|
183
197
|
}
|
|
184
198
|
if (matchingTrigger.type === 'item-scroll-position') {
|
|
185
|
-
const
|
|
186
|
-
|
|
199
|
+
const itemArea = this.items.find((item) => item.id === matchingTrigger.itemId).area[this.layoutId];
|
|
200
|
+
switch (matchingTrigger.itemPosition) {
|
|
201
|
+
case 'top':
|
|
202
|
+
triggerPosition = itemArea.top * window.innerWidth;
|
|
203
|
+
break;
|
|
204
|
+
case 'center':
|
|
205
|
+
triggerPosition = itemArea.top * window.innerWidth - window.innerHeight / 2;
|
|
206
|
+
break;
|
|
207
|
+
case 'bottom':
|
|
208
|
+
triggerPosition = itemArea.top * window.innerWidth - window.innerHeight;
|
|
209
|
+
break;
|
|
210
|
+
default:
|
|
211
|
+
triggerPosition = itemArea.top * window.innerWidth;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
187
214
|
}
|
|
188
215
|
if (!triggerPosition)
|
|
189
216
|
continue;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cntrl-site/sdk-nextjs",
|
|
3
|
-
"version": "1.9.13
|
|
3
|
+
"version": "1.9.13",
|
|
4
4
|
"description": "SDK for Next.js",
|
|
5
5
|
"author": "arsen@momdesign.nyc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@cntrl-site/color": "^1.0.0",
|
|
33
33
|
"@cntrl-site/components": "^0.0.3",
|
|
34
34
|
"@cntrl-site/effects": "^1.4.0",
|
|
35
|
-
"@cntrl-site/sdk": "^1.
|
|
35
|
+
"@cntrl-site/sdk": "^1.25.1-0",
|
|
36
36
|
"@types/vimeo__player": "^2.18.0",
|
|
37
37
|
"@vimeo/player": "^2.25.0",
|
|
38
38
|
"html-react-parser": "^3.0.1",
|
|
@@ -119,7 +119,8 @@ export class InteractionsRegistry implements InteractionsRegistryPort {
|
|
|
119
119
|
for (const interaction of this.interactions) {
|
|
120
120
|
const currentStateId = this.getCurrentStateByInteractionId(interaction.id);
|
|
121
121
|
const matchingTrigger = interaction.triggers.find(trigger =>
|
|
122
|
-
('position' in trigger && trigger.position === 0 && trigger.from === currentStateId)
|
|
122
|
+
('position' in trigger && trigger.position === 0 && trigger.from === currentStateId)
|
|
123
|
+
|| (trigger.type === 'item-scroll-position' && this.items.find((item) => item.id === trigger.itemId) && trigger.from === currentStateId)
|
|
123
124
|
);
|
|
124
125
|
if (!matchingTrigger) continue;
|
|
125
126
|
const activeStateId = this.getActiveInteractionState(interaction.id);
|
|
@@ -170,8 +171,21 @@ export class InteractionsRegistry implements InteractionsRegistryPort {
|
|
|
170
171
|
triggerPosition = trigger.position * window.innerWidth;
|
|
171
172
|
}
|
|
172
173
|
if (trigger.type === 'item-scroll-position') {
|
|
173
|
-
const
|
|
174
|
-
|
|
174
|
+
const itemArea = this.items.find((item) => item.id === trigger.itemId)!.area[this.layoutId];
|
|
175
|
+
switch (trigger.itemPosition) {
|
|
176
|
+
case 'top':
|
|
177
|
+
triggerPosition = itemArea.top * window.innerWidth;
|
|
178
|
+
break;
|
|
179
|
+
case 'center':
|
|
180
|
+
triggerPosition = itemArea.top * window.innerWidth - window.innerHeight / 2;
|
|
181
|
+
break;
|
|
182
|
+
case 'bottom':
|
|
183
|
+
triggerPosition = itemArea.top * window.innerWidth - window.innerHeight;
|
|
184
|
+
break;
|
|
185
|
+
default:
|
|
186
|
+
triggerPosition = itemArea.top * window.innerWidth;
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
175
189
|
}
|
|
176
190
|
if (!triggerPosition) return false;
|
|
177
191
|
const isScrolledPastTrigger = triggerPosition < position;
|
|
@@ -185,8 +199,21 @@ export class InteractionsRegistry implements InteractionsRegistryPort {
|
|
|
185
199
|
triggerPosition = matchingTrigger.position * window.innerWidth;
|
|
186
200
|
}
|
|
187
201
|
if (matchingTrigger.type === 'item-scroll-position') {
|
|
188
|
-
const
|
|
189
|
-
|
|
202
|
+
const itemArea = this.items.find((item) => item.id === matchingTrigger.itemId)!.area[this.layoutId];
|
|
203
|
+
switch (matchingTrigger.itemPosition) {
|
|
204
|
+
case 'top':
|
|
205
|
+
triggerPosition = itemArea.top * window.innerWidth;
|
|
206
|
+
break;
|
|
207
|
+
case 'center':
|
|
208
|
+
triggerPosition = itemArea.top * window.innerWidth - window.innerHeight / 2;
|
|
209
|
+
break;
|
|
210
|
+
case 'bottom':
|
|
211
|
+
triggerPosition = itemArea.top * window.innerWidth - window.innerHeight;
|
|
212
|
+
break;
|
|
213
|
+
default:
|
|
214
|
+
triggerPosition = itemArea.top * window.innerWidth;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
190
217
|
}
|
|
191
218
|
if (!triggerPosition) continue;
|
|
192
219
|
const isScrolledPastTrigger = triggerPosition < position;
|
|
Binary file
|