zydx-plus 1.28.128 → 1.28.130

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,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.28.128",
3
+ "version": "1.28.130",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -4,17 +4,20 @@
4
4
  <div class="book">
5
5
  <div class="pages">
6
6
  <div class="wrap">
7
+ <div class="wrap-one" :class="{'flip-animation-start': flipRights, 'flip-animation-end': flipLefts}" v-if="oneShow" :style="canvasStyle">
8
+ <img :src="imgArr[(oneIndex === 'right')? pageIndex-1: pageIndex]" alt="" />
9
+ </div>
7
10
  <div class="wrap-can">
8
11
  <canvas :id="id"></canvas>
9
12
  </div>
10
13
  </div>
11
- <div class="page-but-left" :style="{cursor: pageIndex === 1?'default':'pointer'}" @click="flipLeft(pageIndex-=1,false)"></div>
12
- <div class="page-but-right" :style="{cursor: pageIndex === pdfPages?'default':'pointer'}" @click="flipRight(pageIndex+=1,false)"></div>
14
+ <div class="page-but-left" :style="{cursor: pageIndex === 1?'default':'pointer'}" @click="flipRight(pageIndex-=1,false)"></div>
15
+ <div class="page-but-right" :style="{cursor: pageIndex === pdfPages?'default':'pointer'}" @click="flipLeft(pageIndex+=1,false)"></div>
13
16
  </div>
14
17
  </div>
15
18
  <div class="but-wrap" v-if="butShow">
16
- <button class="but-brown" :disabled="pageIndex === 1" :class="{'but-act': pageIndex === 1}" @click="flipLeft(pageIndex-=1,false)">上一页</button>
17
- <button class="but-brown" :disabled="pageIndex === pdfPages" :class="{'but-act': pageIndex === pdfPages}" @click="flipRight(pageIndex+=1,false)">下一页</button>
19
+ <button class="but-brown" :disabled="pageIndex === 1" :class="{'but-act': pageIndex === 1}" @click="flipRight(pageIndex-=1,false)">上一页</button>
20
+ <button class="but-brown" :disabled="pageIndex === pdfPages" :class="{'but-act': pageIndex === pdfPages}" @click="flipLeft(pageIndex+=1,false)">下一页</button>
18
21
  </div>
19
22
  </div>
20
23
  <div v-if="loading" class="loading-back">
@@ -43,7 +46,12 @@ export default {
43
46
  pagesData: [],
44
47
  opacity: 1,
45
48
  id: null,
46
- loading: false
49
+ loading: false,
50
+ canvasStyle: {},
51
+ oneShow: false,
52
+ flipRights: false,
53
+ flipLefts: false,
54
+ oneIndex: 'right'
47
55
  }
48
56
  },
49
57
  props: {
@@ -85,12 +93,13 @@ export default {
85
93
  },
86
94
  methods: {
87
95
  flipLeft(e,v) {
88
- if(e < 1) {
89
- this.pageIndex = 1
96
+ if(e >= this.pdfPages) {
97
+ this.pageIndex = this.pdfPages
90
98
  return
91
99
  }else {
92
100
  this.pageIndex = e
93
101
  }
102
+ this.oneIndex = 'right'
94
103
  this.readPdf()
95
104
  if(!v) {
96
105
  this.$emit('flip', {
@@ -100,12 +109,13 @@ export default {
100
109
  }
101
110
  },
102
111
  flipRight(e,v) {
103
- if(e >= this.pdfPages) {
104
- this.pageIndex = this.pdfPages
112
+ if(e < 1) {
113
+ this.pageIndex = 1
105
114
  return
106
115
  }else {
107
116
  this.pageIndex = e
108
117
  }
118
+ this.oneIndex = 'left'
109
119
  this.readPdf()
110
120
  if(!v) {
111
121
  this.$emit('flip', {
@@ -118,17 +128,25 @@ export default {
118
128
  if(this.source === '' || this.source === undefined || this.source === null) return
119
129
  let that = this
120
130
  that.loading = true
131
+ if(that.imgArr[that.pageIndex - 1] !== undefined) {
132
+ that.oneShow = that.pageIndex !== 1
133
+ }
121
134
  const loadingTask = PdfJs.getDocument(this.source)
122
135
  loadingTask.promise.then((pdf) => {
123
136
  that.pdfPages = pdf.numPages // 获取pdf文件的总页数
124
137
  pdf.getPage(that.pageIndex).then(function (page) {
125
138
  let canvas = document.getElementById(that.id)
126
139
  let ctx = canvas.getContext('2d');
127
- let viewport = page.getViewport({scale: 1.4})
140
+ let viewport = page.getViewport({scale: 1.35})
128
141
  canvas.width = viewport.width * 2
129
142
  canvas.height = viewport.height * 2
130
143
  canvas.style.width = viewport.width + 'px'
131
144
  canvas.style.height = viewport.height + 'px'
145
+ that.canvasStyle = {
146
+ width: viewport.width + 'px',
147
+ height: viewport.height + 'px',
148
+ marginLeft: -(viewport.width/2) + 'px'
149
+ }
132
150
  let renderContext = {
133
151
  canvasContext: ctx,
134
152
  viewport: viewport,
@@ -136,6 +154,20 @@ export default {
136
154
  }
137
155
  page.render(renderContext)
138
156
  that.loading = false
157
+ if(that.oneIndex === 'right') {
158
+ that.flipRights = true
159
+ that.flipLefts = false
160
+ }else {
161
+ that.flipRights = false
162
+ that.flipLefts = true
163
+ }
164
+ // 获取canvas的base64数据
165
+ setTimeout(() => {
166
+ that.flipRights = false
167
+ that.flipLefts = false
168
+ that.oneShow = false
169
+ that.imgArr[that.pageIndex] = canvas.toDataURL('image/jpeg', 1)
170
+ }, 1000)
139
171
  })
140
172
  })
141
173
  }
@@ -144,11 +176,64 @@ export default {
144
176
  </script>
145
177
 
146
178
  <style scoped>
179
+ /*动画部分*/
180
+ /*I'm the home page动画*/
181
+ .flip-animation-start {
182
+ transform-origin: left center;
183
+ animation: flipBook1 1s forwards;
184
+ }
185
+ .flip-animation-end {
186
+ transform-origin: left center;
187
+ animation: flipBook2 1s forwards;
188
+ }
189
+ @keyframes flipBook1 {
190
+ 0% {
191
+ transform: perspective(3000px) rotateY(0deg);
192
+ opacity: 1;
193
+ }
194
+ 60%{
195
+ opacity: 1;
196
+ }
197
+ 100% {
198
+ transform: perspective(3000px) rotateY(-160deg);
199
+ opacity: 0;
200
+ }
201
+ }
202
+ /*关闭书页*/
203
+ @keyframes flipBook2 {
204
+ 0% {
205
+ transform: perspective(3000px) rotateY(-160deg);
206
+ opacity: 0;
207
+ }
208
+ 30%{
209
+ opacity: 1;
210
+ }
211
+ 70%{
212
+ opacity: 1;
213
+ }
214
+ 100% {
215
+ transform: perspective(3000px) rotateY(0deg);
216
+ opacity: 0;
217
+ }
218
+ }
219
+ .wrap-one{
220
+ position: absolute;
221
+ top: 0;
222
+ left: 50%;
223
+ right: 0;
224
+ bottom: 0;
225
+ z-index: 1;
226
+ }
227
+ .wrap-one img{
228
+ width: 100%;
229
+ height: 100%;
230
+ }
147
231
  .wrap{
148
232
  width: 100%;
149
233
  height: 100%;
150
234
  display: flex;
151
235
  align-items: center;
236
+ position: relative;
152
237
  }
153
238
  .wrap-can{
154
239
  display: inline-block;
package/src/index.js CHANGED
@@ -67,7 +67,7 @@ function install(app) {
67
67
  }
68
68
 
69
69
  export default {
70
- version: '1.28.128',
70
+ version: '1.28.130',
71
71
  install,
72
72
  Calendar,
73
73
  Message,