Skip to content

Commit f160bfd

Browse files
author
chenxuan
committedJan 17, 2018
💬 will add left/right scroll a few day
近期增加左右无缝滚动配置
1 parent 4575f04 commit f160bfd

File tree

6 files changed

+15
-17
lines changed

6 files changed

+15
-17
lines changed
 

‎README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Example:
8080
```
8181

8282
## Care
83+
I will add left and right seamless scroll in the near future.
8384
I will create a js seamless scrolling plug-in project in the near future.
8485

8586
## License

‎dist/vue-seamless-scroll.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ var arrayEqual = __webpack_require__(42);
310310
exports.default = {
311311
data: function data() {
312312
return {
313+
xPos: 0,
313314
yPos: 0,
314315
delay: 0,
315316
copyHtml: '',
@@ -329,7 +330,7 @@ exports.default = {
329330
},
330331
computed: {
331332
pos: function pos() {
332-
return { transform: 'translate(0,' + this.yPos + 'px)', transition: 'all ease-in ' + this.delay + 'ms' };
333+
return { transform: 'translate(' + this.xPos + 'px,' + this.yPos + 'px)', transition: 'all ease-in ' + this.delay + 'ms' };
333334
},
334335
defaultOption: function defaultOption() {
335336
return {
@@ -376,8 +377,8 @@ exports.default = {
376377
x: touch.pageX - this.startPos.x,
377378
y: touch.pageY - this.startPos.y
378379
};
379-
var direction = Math.abs(this.endPos.x) < Math.abs(this.endPos.y) ? 1 : 0;
380-
if (direction === 1) {
380+
var dir = Math.abs(this.endPos.x) < Math.abs(this.endPos.y) ? 1 : 0;
381+
if (dir === 1) {
381382
event.preventDefault();
382383
this.yPos = this.startPosY + this.endPos.y;
383384
}
@@ -419,12 +420,9 @@ exports.default = {
419420
if (Math.abs(this.yPos) >= h) {
420421
this.yPos = 0;
421422
}
422-
} else {
423-
if (this.yPos >= 0) this.yPos = h * -1;
424-
}
425-
if (direction === 1) {
426423
this.yPos -= this.options.step;
427424
} else {
425+
if (this.yPos >= 0) this.yPos = h * -1;
428426
this.yPos += this.options.step;
429427
}
430428
if (!!this.options.singleHeight) {

‎dist/vue-seamless-scroll.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎document/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Example:
8080
```
8181

8282
## 注意
83+
我将会近期增加左右滚动配置
8384
我将会在近期创建一个js无缝滚动插件项目。
8485

8586
## License

‎examples/examples.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/components/myClass.vue

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
export default {
1515
data () {
1616
return {
17+
xPos: 0,
1718
yPos: 0,
1819
delay: 0,
1920
copyHtml: '',
@@ -32,14 +33,14 @@
3233
},
3334
computed: {
3435
pos () {
35-
return {transform: `translate(0,${this.yPos}px)`, transition: `all ease-in ${this.delay}ms`}
36+
return {transform: `translate(${this.xPos}px,${this.yPos}px)`, transition: `all ease-in ${this.delay}ms`}
3637
},
3738
defaultOption () {
3839
return {
3940
step: 1, //步长
4041
limitMoveNum: 5, //启动无缝滚动最小数据数
4142
hoverStop: true, //是否启用鼠标hover控制
42-
direction: 1, //1 往上 0 往下
43+
direction: 1, // 0 往下 1 往上
4344
openWatch: true, //开启data实时监听
4445
singleHeight: 0, //单条数据高度有值hoverStop关闭
4546
waitTime: 1000 //单步停止等待时间
@@ -79,8 +80,8 @@
7980
x: touch.pageX - this.startPos.x,
8081
y: touch.pageY - this.startPos.y
8182
}
82-
let direction = Math.abs(this.endPos.x) < Math.abs(this.endPos.y) ? 1 : 0 //direction,1表示纵向滑动,0为横向滑动
83-
if (direction === 1) {
83+
let dir = Math.abs(this.endPos.x) < Math.abs(this.endPos.y) ? 1 : 0 //direction,1表示纵向滑动,0为横向滑动
84+
if (dir === 1) {
8485
event.preventDefault(); //阻止触摸事件的默认行为,即阻止滚屏
8586
this.yPos = this.startPosY + this.endPos.y
8687
}
@@ -119,12 +120,9 @@
119120
if (Math.abs(this.yPos) >= h) {
120121
this.yPos = 0
121122
}
122-
} else {
123-
if (this.yPos >= 0) this.yPos = h * -1
124-
}
125-
if (direction === 1) {
126123
this.yPos -= this.options.step
127124
} else {
125+
if (this.yPos >= 0) this.yPos = h * -1
128126
this.yPos += this.options.step
129127
}
130128
if (!!this.options.singleHeight) { //是否启动了单行暂停配置

0 commit comments

Comments
 (0)
Please sign in to comment.