@thinkpixellab-public/px-vue 3.0.69 → 3.0.70

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.
@@ -0,0 +1,50 @@
1
+ <!--
2
+
3
+ Usage:
4
+
5
+ To perform an action the first time the browser tab becomes active, override the browserTabFirstActive() method.
6
+
7
+ To watch for changes to the browser tab's active state, watch the isBrowserTabActive property.
8
+
9
+ -->
10
+ <script>
11
+ export default {
12
+ data() {
13
+ return { isBrowserTabActive: false, browserTabActivationCount: 0 };
14
+ },
15
+ mounted() {
16
+ if (typeof document == undefined) {
17
+ console.warn('Unable to create visibility change listener. No document object.');
18
+ return;
19
+ }
20
+
21
+ document.addEventListener('visibilitychange', this.onTabVisibilityChange);
22
+ this.onTabVisibilityChange();
23
+ },
24
+ beforeDestroy() {
25
+ document.removeEventListener('visibilitychange', this.onTabVisibilityChange);
26
+ },
27
+ methods: {
28
+ onTabVisibilityChange() {
29
+ if (document.visibilityState === 'visible') {
30
+ this.isBrowserTabActive = true;
31
+ this.browserTabActivationCount++;
32
+
33
+ if (this.browserTabActivationCount == 1) {
34
+ if (this.browserTabFirstActive) {
35
+ this.browserTabFirstActive();
36
+ }
37
+ }
38
+ } else {
39
+ this.isBrowserTabActive = false;
40
+ }
41
+ },
42
+
43
+ // OVERRIDE this method to perform an action the first time the browser tab becomes active
44
+ //
45
+ // browserTabFirstActive() {
46
+ // console.log('browser tab first active');}
47
+ // }
48
+ },
49
+ };
50
+ </script>
@@ -0,0 +1,78 @@
1
+ <!--
2
+ Usage:
3
+
4
+ <px-flip :states="['select', 'interact']" :current="'select'">
5
+ <template :state="state">
6
+ <div :class="bem('container', { state })">
7
+ <div data-pxflip>...</div>
8
+ <div data-pxflip>...</div>
9
+ </div>
10
+ </template>
11
+ </px-flip>
12
+ -->
13
+
14
+ <template>
15
+ <div :class="bem()">
16
+ <!-- in the component -->
17
+ <slot name="default" :state="currentStateValue">
18
+ <!-- fallback -->
19
+ </slot>
20
+ </div>
21
+ </template>
22
+
23
+ <script>
24
+ // import { mapState } from 'vuex';
25
+ // import Component from '~/components/Component.vue';
26
+ import { gsap } from 'gsap';
27
+ import { Flip } from 'gsap/Flip';
28
+
29
+ export default {
30
+ name: 'px-flip',
31
+ // components: { Component },
32
+ // mixins: [ Mixin ],
33
+ props: {
34
+ states: { type: Array, default: null },
35
+ current: { type: String, default: null },
36
+ otherProps: { type: String, default: 'opacity,color,backgroundColor' },
37
+ selector: { type: String, default: '[data-flip]' },
38
+ targets: { default: null },
39
+ },
40
+ data() {
41
+ return { currentStateValue: this.current };
42
+ },
43
+ // computed: {},
44
+ watch: {
45
+ async current(nv) {
46
+ const targetElements = this.targets || this.$el.querySelectorAll(this.selector);
47
+
48
+ console.log(targetElements);
49
+
50
+ // save initial state
51
+ const state = Flip.getState(targetElements, { props: this.otherProps, absolute: true });
52
+
53
+ // make state changes
54
+ this.currentStateValue = nv;
55
+
56
+ await this.$nextTick();
57
+ // animate from the old state to the new one
58
+ // animate from the previous state to the current one:
59
+
60
+ Flip.from(state, {
61
+ duration: 1,
62
+ ease: 'power1.inOut',
63
+ absolute: true,
64
+ });
65
+ },
66
+ },
67
+ mounted() {
68
+ gsap.registerPlugin(Flip);
69
+ },
70
+ // methods: {},
71
+ };
72
+ </script>
73
+
74
+ <style lang="scss">
75
+ .px-flip {
76
+ // add styles here
77
+ }
78
+ </style>
@@ -81,13 +81,16 @@ export default {
81
81
  }
82
82
 
83
83
  this.timeline = t;
84
- this.progress = this.timeline.progress();
85
- this.isPlaying = !this.timeline.paused();
86
84
 
87
- this.timeline.eventCallback('onUpdate', () => {
85
+ if (this.timeline) {
88
86
  this.progress = this.timeline.progress();
89
87
  this.isPlaying = !this.timeline.paused();
90
- });
88
+
89
+ this.timeline.eventCallback('onUpdate', () => {
90
+ this.progress = this.timeline.progress();
91
+ this.isPlaying = !this.timeline.paused();
92
+ });
93
+ }
91
94
  },
92
95
  pause() {
93
96
  if (this.timeline) {
@@ -0,0 +1,87 @@
1
+ <!--
2
+ Describe this component...
3
+ -->
4
+ <template>
5
+ <div :class="bem()">
6
+ <PxFlip :states="['open', 'close']" :current="currentState">
7
+ <template #default="{ state }">
8
+ {{ state }}
9
+ <br />
10
+ <br />
11
+ <span :class="bem('container', { state })">
12
+ <span data-flip />
13
+ <span data-flip />
14
+ <span data-flip />
15
+ </span>
16
+ </template>
17
+ </PxFlip>
18
+ <button @click="toggleState">Toggle</button>
19
+ </div>
20
+ </template>
21
+
22
+ <script>
23
+ // import { mapState } from 'vuex';
24
+ // import Component from '~/components/Component.vue';
25
+ // import Mixin from '~/components/Mixin.vue';
26
+
27
+ import PxFlip from '../../components/PxFlip.vue';
28
+
29
+ export default {
30
+ name: 'demo-px-flip',
31
+ components: { PxFlip },
32
+
33
+ // mixins: [ Mixin ],
34
+ // props: { a: { type: Boolean, default: false } },
35
+ data() {
36
+ return {
37
+ currentState: 'open',
38
+ };
39
+ },
40
+ // computed: {},
41
+ // watch: {},
42
+ // mounted() {},
43
+ methods: {
44
+ toggleState() {
45
+ if (this.currentState == 'open') {
46
+ this.currentState = 'close';
47
+ } else {
48
+ this.currentState = 'open';
49
+ }
50
+ },
51
+ },
52
+ };
53
+ </script>
54
+
55
+ <style lang="scss">
56
+ @use '../../styles/px.scss' as *;
57
+ .demo-px-flip {
58
+ padding: 5em;
59
+ &__container {
60
+ width: 4em;
61
+ height: 4em;
62
+ display: flex;
63
+ flex-direction: column;
64
+ justify-content: space-between;
65
+ position: relative;
66
+
67
+ span {
68
+ width: 100%;
69
+ height: 0.5em;
70
+ background-color: currentColor;
71
+ }
72
+
73
+ &--state-open {
74
+ span {
75
+ transform: rotate(0deg) scale(1);
76
+ }
77
+ }
78
+
79
+ &--state-close {
80
+ span {
81
+ transform: scale(0.5);
82
+ opacity: 0.5;
83
+ }
84
+ }
85
+ }
86
+ }
87
+ </style>
package/dev/dev.vue CHANGED
@@ -19,6 +19,7 @@ import DemoPxPivot from './demos/Demo-PxPivot.vue';
19
19
  import DemoPxFloat from './demos/Demo-PxFloat.vue';
20
20
  import DemoPxContain from './demos/Demo-PxContain.vue';
21
21
  import DemoPxMenu from './demos/Demo-PxMenu.vue';
22
+ import DemoPxFlip from './demos/Demo-PxFlip.vue';
22
23
 
23
24
  export default Vue.extend({
24
25
  components: {
@@ -34,6 +35,7 @@ export default Vue.extend({
34
35
  DemoPxFloat,
35
36
  DemoPxContain,
36
37
  DemoPxMenu,
38
+ DemoPxFlip,
37
39
  },
38
40
  name: 'ServeDev',
39
41
  data() {
@@ -46,7 +48,7 @@ export default Vue.extend({
46
48
  const params = new Proxy(new URLSearchParams(window.location.search), {
47
49
  get: (searchParams, prop) => searchParams.get(prop),
48
50
  });
49
- this.componentToRender = params.component || 'DemoPxMenu';
51
+ this.componentToRender = params.component || 'DemoPxFlip';
50
52
  console.log(`this.componentToRender: ${this.componentToRender}`);
51
53
  },
52
54
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.69",
3
+ "version": "3.0.70",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",
@@ -110,8 +110,8 @@ function textElementIsMultipleLines(element) {
110
110
  // Update the first word variable in the dom
111
111
  firstWord = document.getElementById('element-first-word');
112
112
 
113
- firstWordHeight = firstWord.offsetHeight;
114
- elementHeight = element.offsetHeight;
113
+ firstWordHeight = firstWord?.offsetHeight;
114
+ elementHeight = element?.offsetHeight;
115
115
 
116
116
  // Restore the original element text
117
117
  element.innerHTML = ORIGINAL_ELEMENT_TEXT;