@thinkpixellab-public/px-vue 4.0.2 → 4.0.4

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.
@@ -79,11 +79,49 @@ export default {
79
79
  data() {
80
80
  return {
81
81
  direction: 1,
82
+ lastInteractionType: null,
82
83
  activeTransitions: 0,
83
84
  scrollPreview: 0,
84
85
  };
85
86
  },
86
- computed: {},
87
+ computed: {
88
+ lethargyOverrides() {
89
+ // query strings overrides
90
+
91
+ const stability = parseFloat(this.$route.query?.scrollStability);
92
+ const sensitivity = parseFloat(this.$route.query?.scrollSensitivity);
93
+ const tolerance = parseFloat(this.$route.query?.scrollTolerance);
94
+
95
+ if (stability || sensitivity || tolerance) {
96
+ console.log('[Custom scroll values enabled.]');
97
+ console.log(`stability: ${stability || 8}`);
98
+ console.log(`sensitivity: ${sensitivity || 100}`);
99
+ console.log(`tolerance: ${tolerance || 1.1}`);
100
+
101
+ return {
102
+ stability: stability || 8,
103
+ sensitivity: sensitivity || 100,
104
+ tolerance: tolerance || 1.1,
105
+ };
106
+ }
107
+
108
+ // windows overrides
109
+
110
+ if (
111
+ navigator.userAgent.indexOf('Win') != -1 ||
112
+ this.$route.query?.scroll == 'windows'
113
+ ) {
114
+ //console.log('[Windows scroll values enabled.]');
115
+ return {
116
+ stability: stability || 8,
117
+ sensitivity: sensitivity || 20,
118
+ tolerance: tolerance || 0.1,
119
+ };
120
+ }
121
+
122
+ return null;
123
+ },
124
+ },
87
125
  watch: {
88
126
  selectedData(nv, ov) {
89
127
  let newIndex = this.itemKeys.indexOf(nv);
@@ -94,8 +132,11 @@ export default {
94
132
  oldKey: ov,
95
133
  index: newIndex,
96
134
  previousIndex: oldIndex,
135
+ interactionType: this.lastInteractionType,
97
136
  });
98
137
 
138
+ this.lastInteractionType = null;
139
+
99
140
  newIndex = this.selectedRelativeIndex(newIndex);
100
141
  oldIndex = this.selectedRelativeIndex(oldIndex);
101
142
 
@@ -123,6 +164,20 @@ export default {
123
164
  });
124
165
 
125
166
  if (this.scrollEnabled) {
167
+ let overrides = this.lethargyOverrides;
168
+
169
+ if (overrides) {
170
+ this.lethargy = new Lethargy(
171
+ overrides.stability,
172
+ overrides.sensitivity,
173
+ overrides.tolerance
174
+ );
175
+ } else {
176
+ this.lethargy = new Lethargy();
177
+ }
178
+
179
+ this.lethargyPrevCheck = false;
180
+
126
181
  this.$el.addEventListener('wheel', this.onWheel);
127
182
  }
128
183
  },
@@ -172,6 +227,9 @@ export default {
172
227
  if (Math.abs(ev.delta.x) < 10) {
173
228
  gsap.to(this.dragElements, { x: 0 });
174
229
  } else {
230
+ this.lastInteractionType = 'drag';
231
+ this.$emit('drag-complete');
232
+
175
233
  if (ev.delta.x > 0) {
176
234
  this.previous();
177
235
  } else {
@@ -181,11 +239,6 @@ export default {
181
239
  },
182
240
 
183
241
  onWheel(e) {
184
- if (typeof this.lethargy == 'undefined') {
185
- this.lethargy = new Lethargy();
186
- this.lethargyPrevCheck = false;
187
- }
188
-
189
242
  if (this.scrollPreviewEnabled) {
190
243
  const delta = (e.deltaY + e.deltaX) / 2;
191
244
  if (Math.abs(delta) > 5) {
@@ -202,6 +255,9 @@ export default {
202
255
 
203
256
  if (check !== this.lethargyPrevCheck) {
204
257
  if (check) {
258
+ this.lastInteractionType = 'scroll';
259
+ this.$emit('scroll-complete');
260
+
205
261
  if (check > 0) {
206
262
  this.previous(false);
207
263
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",
package/plugins/common.js CHANGED
@@ -48,7 +48,7 @@ export default {
48
48
 
49
49
  // $eventBus is only client-side but we want to avoid warnings about missing $eventBus
50
50
  // for inject called during setup on server-side.
51
- if (process.server) {
51
+ if (isServer()) {
52
52
  app.provide('$eventBus', null);
53
53
  }
54
54
  },