Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0084f44

Browse files
committed
0.3.0 scrollTo 接受 null
1 parent 8ce65aa commit 0084f44

File tree

6 files changed

+110
-90
lines changed

6 files changed

+110
-90
lines changed

‎README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ export default {
150150
export default {
151151
methods:{
152152
scrollTo(){
153-
// 水平滚50个像素,垂直滚100个像素,在300ms内完成
154-
this.$refs.ohyeah.scrollTo(50, 100, 300);
153+
// 水平保持原位,垂直滚100个像素,在300ms内完成
154+
this.$refs.ohyeah.scrollTo(null, 100, 300);
155155
},
156156
scrollToEnd(){
157157
// 水平滚到最左边,垂直滚到底,瞬间完成
@@ -210,6 +210,7 @@ export default {
210210
- 那么就需要一个具有高度和宽度的父级元素来包裹ohyeah
211211

212212
### 更新
213+
- 0.3.0 this.$refs.ohyeah.scrollTo(null, 100); 传递null表示保持原位不动
213214
- 0.2.9 处理了一下nuxt.js中使用的情况。修复了卸载组件时没有正确卸载容器监听的方法
214215
- 2019年05月09日 处理了嵌套滚动条的事件冒泡问题
215216
> 原生滚动条(子)和ohyeah(父)嵌套时,原生滚动条需要设置@wheel.stop, todo: 目前的方案不完美,待升级

‎dist/ohyeah-scroll.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.

‎package.json‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-ohyeah-scroll",
33
"description": "prettier scroll",
4-
"version": "0.2.9",
4+
"version": "0.3.0",
55
"author": "L <https://blog.isluo.com>",
66
"license": "MIT",
77
"private": false,
@@ -30,18 +30,18 @@
3030
"vue": "^2.6.10"
3131
},
3232
"devDependencies": {
33-
"@babel/core": "^7.4.4",
34-
"@babel/preset-env": "^7.4.4",
35-
"babel-loader": "^8.0.5",
33+
"@babel/core": "^7.4.5",
34+
"@babel/preset-env": "^7.4.5",
35+
"babel-loader": "^8.0.6",
3636
"cross-env": "^5.2.0",
3737
"css-loader": "^2.1.1",
3838
"file-loader": "^3.0.1",
3939
"node-sass": "^4.12.0",
4040
"sass-loader": "^7.1.0",
4141
"vue-loader": "^15.7.0",
4242
"vue-template-compiler": "^2.6.10",
43-
"webpack": "^4.31.0",
43+
"webpack": "^4.32.2",
4444
"webpack-cli": "^3.3.2",
45-
"webpack-dev-server": "^3.3.1"
45+
"webpack-dev-server": "^3.4.1"
4646
}
4747
}

‎src/App.vue‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export default {
9696
//console.log("正在滚动:", obj);
9797
},
9898
onScrollTo() {
99-
this.$refs.scroll1.scrollTo("end", "end", 300);
99+
this.$refs.scroll1.scrollTo("end", null, 300);
100100
},
101101
onHorStart(obj) {
102102
console.log("到左了:", obj);

‎src/packages/ohyeah/ohyeah.vue‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ export default {
383383
}
384384
},
385385
386-
scrollTo(x=0, y=0, time = 0) {
386+
scrollTo(x, y, time = 0) {
387387
const s_y =
388388
y === "end"
389389
? this.trickH - this.barHTall
@@ -398,13 +398,13 @@ export default {
398398
: 0;
399399
400400
this.transSpeed = time;
401-
if (this.realShowH) {
401+
if (this.realShowH&& (y || y ===0)) {
402402
this.barHScrollTop = Math.min(
403403
Math.max(s_y, 0),
404404
this.trickH - this.barHTall
405405
);
406406
}
407-
if (this.realShowW) {
407+
if (this.realShowW&& (x || x ===0)) {
408408
this.barWScrollLeft = Math.min(
409409
Math.max(s_x, 0),
410410
this.trickW - this.barWTall

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /