@mixd-id/web-scaffold 0.1.2301231324 → 0.1.2301231325

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.2301231324",
4
+ "version": "0.1.2301231325",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -3,12 +3,12 @@
3
3
  <div :class="$style.inner">
4
4
  <span v-if="images && images.length && images.length > 0" v-for="image in images" :key="image">
5
5
  <a v-if="image.target && image.target.indexOf('://') >= 0" :href="image.target" @click="checkClick">
6
- <Image :src="image.imageUrl" :class="imageClass" />
6
+ <Image :src="image.imageUrl" :outerClass="imageClass" />
7
7
  </a>
8
8
  <router-link v-if="image.target" :to="scrolling ? '' : image.target">
9
- <Image :src="image.imageUrl" :class="imageClass"/>
9
+ <Image :src="image.imageUrl" :outerClass="imageClass"/>
10
10
  </router-link>
11
- <Image v-else :src="image.imageUrl" :class="imageClass" />
11
+ <Image v-else :src="image.imageUrl" :outerClass="imageClass" />
12
12
  </span>
13
13
  <div v-else :class="imageClass" class="bg-gray-200 animate-pulse"></div>
14
14
  </div>
@@ -5,7 +5,7 @@
5
5
  <img :class="computedClass" :src="actualSrc" ref="img" :style="imageStyle"/>
6
6
  <input v-if="Boolean(editable)" class="hidden" type="file" accept="image/*" ref="file" @change="onChange"/>
7
7
  <slot></slot>
8
- <div :class="$style.isLoading" v-if="isLoading">
8
+ <div :class="$style.loading" v-if="loading">
9
9
  <svg class="animate-spin aspect-square w-[15%] text-primary" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg>
10
10
  </div>
11
11
  </div>
@@ -80,8 +80,7 @@ export default{
80
80
 
81
81
  data(){
82
82
  return {
83
- visible: 0,
84
- isLoading: false,
83
+ loading: false,
85
84
  actualSrc: null,
86
85
  loaded: false
87
86
  }
@@ -113,10 +112,8 @@ export default{
113
112
 
114
113
  async loadSrc(){
115
114
 
116
- this.loaded = false
117
-
118
115
  if(typeof this.src === 'string') {
119
- if (this.src.startsWith('data:image')) {
116
+ if (!this.loaded && this.src.startsWith('data:image')) {
120
117
  this.loaded = true
121
118
  this.actualSrc = this.src
122
119
  }
@@ -139,34 +136,36 @@ export default{
139
136
  img.addEventListener('load', () => {
140
137
  this.loaded = true
141
138
  this.actualSrc = img.src
142
- this.isLoading = false
139
+ this.loading = false
143
140
  })
144
141
  img.addEventListener('error', () => {
145
142
  this.loaded = true
146
143
  this.actualSrc = this.defaultSrc
147
- this.isLoading = false
144
+ this.loading = false
148
145
  })
149
146
  img.src = src[screens[b]]
147
+ this.loading = true
150
148
  }
151
149
  }
152
150
  }
153
151
  }
154
- else if(this.src instanceof File){
152
+ else if(!this.loaded && this.src instanceof File){
155
153
  var reader = new FileReader();
156
154
 
157
155
  reader.addEventListener('load', () => {
158
156
  this.loaded = true
159
157
  this.actualSrc = reader.result
160
- this.isLoading = false
158
+ this.loading = false
161
159
  }, false)
162
160
 
163
161
  reader.addEventListener('error', () => {
164
162
  this.loaded = true
165
163
  this.actualSrc = this.defaultSrc
166
- this.isLoading = false
164
+ this.loading = false
167
165
  })
168
166
 
169
167
  reader.readAsDataURL(this.src)
168
+ this.loading = true
170
169
  }
171
170
  }
172
171
 
@@ -175,14 +174,12 @@ export default{
175
174
  watch:{
176
175
 
177
176
  src(to){
177
+ this.loaded = false
178
178
  this.loadSrc()
179
+ },
179
180
 
180
- window.setTimeout(() => {
181
- if(!this.loaded){
182
- this.actualSrc = null
183
- this.isLoading = true
184
- }
185
- }, 200)
181
+ "isMobile.value"(to){
182
+ this.loadSrc()
186
183
  }
187
184
 
188
185
  }
@@ -200,7 +197,7 @@ export default{
200
197
  @apply absolute top-0 left-0 right-0 bottom-0;
201
198
  }
202
199
 
203
- .isLoading{
200
+ .loading{
204
201
  @apply absolute top-0 left-0 right-0 bottom-0;
205
202
  @apply flex items-center justify-center;
206
203
  }
package/src/index.js CHANGED
@@ -40,7 +40,7 @@ export default{
40
40
 
41
41
  window.addEventListener('resize', throttle(() => {
42
42
  isMobile.value = calculateIsMobile()
43
- }, 600, { trailing:true }))
43
+ }, 300, { trailing:true }))
44
44
  }
45
45
 
46
46
  app.config.globalProperties.uniqid = uniqid