@thinkpixellab-public/px-vue 3.0.64 → 3.0.65

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.
@@ -17,6 +17,7 @@ ar
17
17
  <template>
18
18
  <div :class="bem()">
19
19
  <button
20
+ v-if="!disabled"
20
21
  :class="[bem('button', { start: true, visible: arrowStartVisible }), buttonClass]"
21
22
  @click="scrollPages(-1)"
22
23
  aria-label="Scroll to previous"
@@ -29,11 +30,12 @@ ar
29
30
  </slot>
30
31
  </button>
31
32
 
32
- <div :class="bem('scroller')" ref="scroller" @scroll="updateScrollArrows">
33
+ <div :class="bem('scroller', { disabled })" ref="scroller" @scroll="updateScrollArrows">
33
34
  <slot />
34
35
  </div>
35
36
 
36
37
  <button
38
+ v-if="!disabled"
37
39
  :class="[bem('button', { end: true, visible: arrowEndVisible }), buttonClass]"
38
40
  @click="scrollPages(1)"
39
41
  aria-label="Scroll to next"
@@ -63,6 +65,7 @@ export default {
63
65
  arrowStartSrc: { type: String, default: require('../assets/icons/nav-prev.svg') },
64
66
  arrowEndSrc: { type: String, default: require('../assets/icons/nav-next.svg') },
65
67
  buttonClass: { type: String, default: null },
68
+ disabled: { type: Boolean, default: false },
66
69
  },
67
70
  data() {
68
71
  return {
@@ -161,6 +164,9 @@ export default {
161
164
  grid-area: scroller;
162
165
  overflow-x: auto;
163
166
  @include invisible-scrollbar;
167
+ &--disabled {
168
+ overflow-x: hidden;
169
+ }
164
170
  }
165
171
  }
166
172
  </style>
@@ -6,54 +6,61 @@
6
6
  -->
7
7
  <template>
8
8
  <div
9
- :class="bem({ scrolls: scrolls, animated: animated, loading: loading })"
9
+ :class="bem({ animated: animated, loading: loading })"
10
10
  :style="{ opacity: loading ? 0 : null }"
11
11
  >
12
- <div :class="bem('tabs-align', { justify: justify })">
13
- <div ref="tabs" :class="bem('tabs')">
14
- <button
15
- :class="[bem('tab-base', { selected: isItemSelected(item) }), tabClass]"
16
- v-for="item in items"
17
- :key="getItemKey(item)"
18
- :disabled="getItemDisabled(item)"
19
- @click="itemClick(item)"
20
- v-bind="getTabAttrs(item)"
21
- >
22
- <span :ref="getTabContentRefName(item)">
23
- <slot :item="item" :selected="isItemSelected(item)">
24
- {{ getItemLabel(item) }}
25
- </slot>
26
- </span>
27
- </button>
28
-
29
- <div
30
- :class="[bem('selector-base'), selectorClass]"
31
- :style="{
32
- left: cssPx(selectorOffset),
33
- width: cssPx(selectorWidth),
34
- }"
35
- >
36
- <slot name="selector"></slot>
12
+ <PxArrowScroller :disabled="!scrolls">
13
+ <div :class="bem('grid')">
14
+ <div :class="bem('tabs-align', { justify: justify })">
15
+ <div ref="tabs" :class="bem('tabs')">
16
+ <button
17
+ :class="[bem('tab-base', { selected: isItemSelected(item) }), tabClass]"
18
+ v-for="item in items"
19
+ :key="getItemKey(item)"
20
+ :disabled="getItemDisabled(item)"
21
+ @click="itemClick(item)"
22
+ v-bind="getTabAttrs(item)"
23
+ >
24
+ <span :ref="getTabContentRefName(item)">
25
+ <slot :item="item" :selected="isItemSelected(item)">
26
+ {{ getItemLabel(item) }}
27
+ </slot>
28
+ </span>
29
+ </button>
30
+
31
+ <div
32
+ :class="[bem('selector-base'), selectorClass]"
33
+ :style="{
34
+ left: cssPx(selectorOffset),
35
+ width: cssPx(selectorWidth),
36
+ }"
37
+ >
38
+ <slot name="selector"></slot>
39
+ </div>
40
+ </div>
37
41
  </div>
38
42
  </div>
39
- </div>
43
+ </PxArrowScroller>
40
44
  </div>
41
45
  </template>
42
46
 
43
47
  <script>
44
48
  import PxBaseItemsSelect from './PxBaseItemsSelect.vue';
45
49
  import PxBaseResize from './PxBaseResize.vue';
50
+ import PxArrowScroller from './PxArrowScroller.vue';
46
51
  import utils from '../utils/utils.js';
47
52
 
48
53
  export default {
49
54
  name: 'px-pivot',
50
- components: {},
55
+ components: { PxArrowScroller },
51
56
  mixins: [PxBaseResize, PxBaseItemsSelect],
52
57
  props: {
53
58
  // classes that get set on the tabs and selector line
54
59
  tabClass: { type: String, default: 'px-pivot__tab' },
55
60
  selectorClass: { type: String, default: 'px-pivot__selector' },
56
61
 
62
+ animateSelector: { type: Boolean, default: true },
63
+
57
64
  // a function that will return attributes that should be set on the tab buttons (takes the
58
65
  // button item as an arg)
59
66
  tabAttrsFn: { type: Function, default: null },
@@ -74,6 +81,7 @@ export default {
74
81
  selectorWidth: 0,
75
82
  animated: false,
76
83
  loading: true,
84
+ resizing: false,
77
85
  };
78
86
  },
79
87
  // computed: {},
@@ -127,7 +135,11 @@ export default {
127
135
  }
128
136
 
129
137
  if (this.scrolls) {
130
- selected.scrollIntoView({ behavior: 'smooth', inline: 'center' });
138
+ selected.scrollIntoView({
139
+ behavior: 'smooth',
140
+ inline: 'nearest',
141
+ block: 'nearest',
142
+ });
131
143
  }
132
144
  },
133
145
 
@@ -139,11 +151,17 @@ export default {
139
151
  },
140
152
 
141
153
  itemClick(item) {
142
- this.animated = true;
143
- this.selectItemOnly(item);
144
- setTimeout(() => {
154
+ clearTimeout(this.animateTimeout);
155
+
156
+ this.animated = this.animateSelector;
157
+
158
+ this.$nextTick(() => {
159
+ this.selectItemOnly(item);
160
+ });
161
+
162
+ this.animateTimeout = setTimeout(() => {
145
163
  this.animated = false;
146
- }, 100);
164
+ }, 1000);
147
165
  },
148
166
 
149
167
  getTabAttrs(item) {
@@ -159,9 +177,6 @@ export default {
159
177
  <style lang="scss">
160
178
  @use '../styles/px.scss' as *;
161
179
  .px-pivot {
162
- display: grid;
163
- grid-template-columns: minmax(min-content, 100%);
164
-
165
180
  // disable animation until loaded
166
181
  &--loading {
167
182
  * {
@@ -169,18 +184,28 @@ export default {
169
184
  }
170
185
  }
171
186
 
187
+ // * {
188
+ // transition: none !important;
189
+ // }
190
+
172
191
  --px-pivot-tab-padding: 0.5em;
173
192
  --px-pivot-tab-offset: -0.5em;
174
193
 
175
- &--scrolls {
176
- max-width: 100%;
177
- overflow-x: auto;
178
- -webkit-overflow-scrolling: touch;
179
- @include invisible-scrollbar();
194
+ // &--scrolls {
195
+ // max-width: 100%;
196
+ // overflow-x: auto;
197
+ // -webkit-overflow-scrolling: touch;
198
+ // @include invisible-scrollbar();
199
+ // }
200
+
201
+ &__grid {
202
+ display: grid;
203
+ grid-template-columns: minmax(min-content, 100%);
180
204
  }
181
205
 
182
206
  &__tabs-align {
183
207
  min-width: 100%;
208
+ width: auto;
184
209
  display: flex;
185
210
  position: relative;
186
211
  &--justify-center {
@@ -229,8 +254,8 @@ export default {
229
254
  }
230
255
 
231
256
  &--animated & {
232
- &__selector {
233
- @include transition(width left);
257
+ &__selector-base {
258
+ @include transition(left width opacity, $dur: 400ms, $ease: $ease-out-quart);
234
259
  }
235
260
  }
236
261
 
@@ -175,7 +175,7 @@ export default {
175
175
 
176
176
  this.lethargyPrevCheck = false;
177
177
 
178
- this.$el.addEventListener('wheel', this.onWheel);
178
+ this.$el.addEventListener('wheel', this.onWheel, { passive: true });
179
179
  }
180
180
 
181
181
  this.drag = new Drag(this.$el, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.64",
3
+ "version": "3.0.65",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",