@cntrl-site/sdk-nextjs 1.9.17-0 → 1.9.17
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.
|
@@ -90,9 +90,30 @@ class InteractionsRegistry {
|
|
|
90
90
|
}
|
|
91
91
|
return itemStyles;
|
|
92
92
|
}
|
|
93
|
+
isItemScrollBasedTrigger(itemId) {
|
|
94
|
+
let isElementHasScrollBasedTrigger = false;
|
|
95
|
+
for (const interaction of this.interactions) {
|
|
96
|
+
const hasInteractionItemScrollBasedTrigger = interaction.triggers.find((tr) => (tr.type === 'item-scroll-position' && tr.itemId === itemId)) !== undefined;
|
|
97
|
+
const hasInteractionScrollBasedTrigger = interaction.triggers.find((tr) => tr.type === 'scroll-position') !== undefined;
|
|
98
|
+
if (hasInteractionScrollBasedTrigger) {
|
|
99
|
+
for (const trigger of interaction.triggers) {
|
|
100
|
+
if (trigger.type === 'item' && trigger.itemId === itemId) {
|
|
101
|
+
isElementHasScrollBasedTrigger = true;
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (hasInteractionItemScrollBasedTrigger) {
|
|
107
|
+
isElementHasScrollBasedTrigger = true;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return isElementHasScrollBasedTrigger;
|
|
111
|
+
}
|
|
93
112
|
getItemAvailableTriggers(itemId) {
|
|
94
113
|
const available = new Set();
|
|
95
114
|
const activeStates = Object.values(this.interactionStateMap);
|
|
115
|
+
if (this.isItemScrollBasedTrigger(itemId))
|
|
116
|
+
return available;
|
|
96
117
|
for (const interaction of this.interactions) {
|
|
97
118
|
const { triggers } = interaction;
|
|
98
119
|
for (const trigger of triggers) {
|
|
@@ -307,14 +328,15 @@ class InteractionsRegistry {
|
|
|
307
328
|
notifyItemTrigger(itemId, triggerType) {
|
|
308
329
|
var _a, _b;
|
|
309
330
|
const timestamp = Date.now();
|
|
331
|
+
if (this.isItemScrollBasedTrigger(itemId))
|
|
332
|
+
return;
|
|
310
333
|
for (const interaction of this.interactions) {
|
|
311
334
|
const currentStateId = this.getCurrentStateByInteractionId(interaction.id);
|
|
312
|
-
const hasInteractionScrollBasedTrigger = interaction.triggers.find((tr) => tr.type === 'item-scroll-position' || tr.type === 'scroll-position') !== undefined;
|
|
313
335
|
const matchingTrigger = interaction.triggers.find((trigger) => 'triggerEvent' in trigger
|
|
314
336
|
&& trigger.itemId === itemId
|
|
315
337
|
&& trigger.from === currentStateId
|
|
316
338
|
&& trigger.triggerEvent === triggerType);
|
|
317
|
-
if (!matchingTrigger
|
|
339
|
+
if (!matchingTrigger)
|
|
318
340
|
continue;
|
|
319
341
|
const activeStateId = this.getActiveInteractionState(interaction.id);
|
|
320
342
|
const isNewStateActive = matchingTrigger.to === activeStateId;
|
package/package.json
CHANGED
|
@@ -102,9 +102,30 @@ export class InteractionsRegistry implements InteractionsRegistryPort {
|
|
|
102
102
|
return itemStyles;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
+
isItemScrollBasedTrigger(itemId: string): boolean {
|
|
106
|
+
let isElementHasScrollBasedTrigger = false;
|
|
107
|
+
for (const interaction of this.interactions) {
|
|
108
|
+
const hasInteractionItemScrollBasedTrigger = interaction.triggers.find((tr) => (tr.type === 'item-scroll-position' && tr.itemId === itemId)) !== undefined;
|
|
109
|
+
const hasInteractionScrollBasedTrigger = interaction.triggers.find((tr) => tr.type === 'scroll-position') !== undefined;
|
|
110
|
+
if (hasInteractionScrollBasedTrigger) {
|
|
111
|
+
for (const trigger of interaction.triggers) {
|
|
112
|
+
if (trigger.type === 'item' && trigger.itemId === itemId) {
|
|
113
|
+
isElementHasScrollBasedTrigger = true;
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (hasInteractionItemScrollBasedTrigger) {
|
|
119
|
+
isElementHasScrollBasedTrigger = true;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return isElementHasScrollBasedTrigger;
|
|
123
|
+
}
|
|
124
|
+
|
|
105
125
|
getItemAvailableTriggers(itemId: string): Set<InteractionItemTrigger['triggerEvent']> {
|
|
106
126
|
const available = new Set<InteractionItemTrigger['triggerEvent']>();
|
|
107
127
|
const activeStates = Object.values(this.interactionStateMap);
|
|
128
|
+
if (this.isItemScrollBasedTrigger(itemId)) return available;
|
|
108
129
|
for (const interaction of this.interactions) {
|
|
109
130
|
const { triggers } = interaction;
|
|
110
131
|
for (const trigger of triggers) {
|
|
@@ -312,16 +333,16 @@ export class InteractionsRegistry implements InteractionsRegistryPort {
|
|
|
312
333
|
|
|
313
334
|
notifyItemTrigger(itemId: string, triggerType: TriggerType): void {
|
|
314
335
|
const timestamp = Date.now();
|
|
336
|
+
if (this.isItemScrollBasedTrigger(itemId)) return;
|
|
315
337
|
for (const interaction of this.interactions) {
|
|
316
338
|
const currentStateId = this.getCurrentStateByInteractionId(interaction.id);
|
|
317
|
-
const hasInteractionScrollBasedTrigger = interaction.triggers.find((tr) => tr.type === 'item-scroll-position' || tr.type === 'scroll-position') !== undefined;
|
|
318
339
|
const matchingTrigger = interaction.triggers.find((trigger) =>
|
|
319
340
|
'triggerEvent' in trigger
|
|
320
341
|
&& trigger.itemId === itemId
|
|
321
342
|
&& trigger.from === currentStateId
|
|
322
343
|
&& trigger.triggerEvent === triggerType
|
|
323
344
|
);
|
|
324
|
-
if (!matchingTrigger
|
|
345
|
+
if (!matchingTrigger) continue;
|
|
325
346
|
const activeStateId = this.getActiveInteractionState(interaction.id);
|
|
326
347
|
const isNewStateActive = matchingTrigger.to === activeStateId;
|
|
327
348
|
this.setCurrentStateForInteraction(interaction.id, matchingTrigger.to);
|