Browse Source

Merge remote-tracking branch 'origin/vue3-vite' into vue3-vite

# Conflicts:
#	src/pages/test/slide.js
pull/19/head
zyronon 4 years ago
parent
commit
fe1fec2afe
  1. BIN
      src/assets/img/icon/components/share/bizhi.png
  2. BIN
      src/assets/img/icon/components/share/collectYellow.png
  3. BIN
      src/assets/img/icon/components/share/comeon.png
  4. BIN
      src/assets/img/icon/components/share/copyLink.png
  5. BIN
      src/assets/img/icon/components/share/copyPassword.png
  6. BIN
      src/assets/img/icon/components/share/dou.png
  7. BIN
      src/assets/img/icon/components/share/duoshan.png
  8. BIN
      src/assets/img/icon/components/share/qq.png
  9. BIN
      src/assets/img/icon/components/share/report.png
  10. BIN
      src/assets/img/icon/components/share/totoutiao.png
  11. BIN
      src/assets/img/icon/components/share/weChat.png
  12. BIN
      src/assets/img/icon/components/share/weChatZone.png
  13. 1
      src/pages/test/TestSlide.vue
  14. 91
      src/pages/test/slide.js

BIN
src/assets/img/icon/components/share/bizhi.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
src/assets/img/icon/components/share/collectYellow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

BIN
src/assets/img/icon/components/share/comeon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
src/assets/img/icon/components/share/copyLink.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
src/assets/img/icon/components/share/copyPassword.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

BIN
src/assets/img/icon/components/share/dou.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
src/assets/img/icon/components/share/duoshan.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

BIN
src/assets/img/icon/components/share/qq.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
src/assets/img/icon/components/share/report.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

BIN
src/assets/img/icon/components/share/totoutiao.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
src/assets/img/icon/components/share/weChat.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

BIN
src/assets/img/icon/components/share/weChatZone.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

1
src/pages/test/TestSlide.vue

@ -69,6 +69,7 @@ export default {
.slide-list { .slide-list {
display: flex; display: flex;
flex-direction: column;
height: 100%; height: 100%;
width: 100%; width: 100%;
position: relative; position: relative;

91
src/pages/test/slide.js

@ -3,24 +3,46 @@ import * as Vue from "vue";
export default class Slide { export default class Slide {
constructor(id, config) { constructor(id, config) {
let container = new Dom(id) this.wrapper = this.create('<div class="slide-wrapper"></div>')
this.wrapper = new Dom().create('<div class="slide-wrapper"></div>') this.list = this.create('<div class="slide-list"></div>')
this.list = new Dom().create('<div class="slide-list"></div>') this.list.addEventListener('touchstart', this.touchstart.bind(this))
this.list.els[0].addEventListener('touchstart', this.touchstart.bind(this)) this.list.addEventListener('touchmove', this.touchmove.bind(this))
this.list.els[0].addEventListener('touchmove', this.touchmove.bind(this)) this.list.addEventListener('touchend', this.touchend.bind(this))
this.list.els[0].addEventListener('touchend', this.touchend.bind(this)) this.wrapper.appendChild(this.list)
this.wrapper.append(this.list) new Dom(id).append(new Dom(this.wrapper))
container.append(this.wrapper) // let container = document.querySelector(id)
// console.log(container)
// container.appendChild(this.wrapper)
this.totalSize = 52 this.totalSize = 52
this.pageSize = 10 this.pageSize = 10
this.pageNo = 0 this.pageNo = 0
this.judgeValue = 0 this.judgeValue = 0
this.currentIndex = 0
this.startTime = 0
this.startLocationX = 0
this.startLocationY = 0
this.moveXDistance = 0
this.moveYDistance = 0
this.height = 812
this.isDrawDown = true this.isDrawDown = true
this.config = config this.config = config
this.appInsMap = new Map() this.appInsMap = new Map()
this.getData() this.getData()
}
console.log(this.list) create(template) {
let tempNode = document.createElement('div');
tempNode.innerHTML = template.trim();
return tempNode.firstChild;
}
css(el, ...args) {
el.style[args[0]] = args[1]
} }
async getData() { async getData() {
@ -29,9 +51,9 @@ export default class Slide {
if (res.code === 200) { if (res.code === 200) {
res.data.list.map((v, i) => { res.data.list.map((v, i) => {
let el = this.getInsEl(v, i, false) let el = this.getInsEl(v, i, false)
let item = new Dom().create('<div class="slide-item"></div>') let item = this.create('<div class="slide-item"></div>')
item.append(new Dom(el)) item.appendChild(el)
this.list.append(item) this.list.appendChild(item)
}) })
} }
} }
@ -57,6 +79,9 @@ export default class Slide {
this.startLocationX = e.touches[0].pageX this.startLocationX = e.touches[0].pageX
this.startLocationY = e.touches[0].pageY this.startLocationY = e.touches[0].pageY
this.startTime = Date.now() this.startTime = Date.now()
console.log('touchstart', this.startTime)
this.css(this.list, 'transition-duration', '0ms')
} }
touchmove(e) { touchmove(e) {
@ -65,16 +90,50 @@ export default class Slide {
// console.log('touchmove', this.moveXDistance) // console.log('touchmove', this.moveXDistance)
// console.log('touchmove', this.moveYDistance) // console.log('touchmove', this.moveYDistance)
this.list.css('transform', `translate3d(0,100px,0)`)
this.list.css('transform', `translate3d(0px, ${ this.css(this.list, 'transform', `translate3d(0px, ${
this.moveYDistance + this.getHeight() + this.moveYDistance +
(this.isDrawDown ? this.judgeValue : -this.judgeValue) (this.isDrawDown ? this.judgeValue : -this.judgeValue)
}px, 0px)`) }px, 0px)`)
}
getHeight() {
return -this.currentIndex * this.height
} }
touchend() { touchend() {
console.log('touchend')
let endTime = Date.now()
let gapTime = endTime - this.startTime
if (Math.abs(this.moveYDistance) < 20) gapTime = 1000
if (Math.abs(this.moveYDistance) > (this.height / 3)) gapTime = 100
// console.log(gapTime)
this.currentIndex += 1
console.log('currentIndex', this.currentIndex)
this.css(this.list, 'transition-duration', '300ms')
this.css(this.list, 'transform', `translate3d(0px, ${
this.getHeight()
}px, 0px)`)
return
if (gapTime < 150) {
if (this.isDrawDown) {
this.currentIndex += 1
} else {
this.currentIndex -= 1
}
console.log(1)
this.currentIndex += 1
this.css(this.list, 'transition-duration', '300ms')
this.css(this.list, 'transform', `translate3d(0px, ${
this.currentIndex * this.height
}px, 0px)`)
}
} }
} }
Loading…
Cancel
Save