Skip to content

Commit 862b121

Browse files
committed
fix: Incorrect bar status after mounted.
1 parent 87632ea commit 862b121

File tree

10 files changed

+53
-33
lines changed

10 files changed

+53
-33
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
## Introduction
2020

21-
Vuescroll is a customizable, multi-mode driven scrollbar plugin based on Vue.js - [vuescrolljs.yvescoding.org](http://vuescrolljs.yvescoding.org/)
21+
Vuescroll is a full customizable scrollbar based on Vue.js, which spports pull-to-refresh and push-to-load. - [vuescrolljs.yvescoding.org](http://vuescrolljs.yvescoding.org/)
2222

23-
You can use it on PC or mobile by changing its mode.
23+
It is compitable with both PC and mobile phone.
2424

2525
## Features
2626

dist/vuescroll-native.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1855,8 +1855,13 @@ var updateNative = {
18551855
var core$1 = {
18561856
mixins: [api$1, updateNative],
18571857
mounted: function mounted() {
1858+
var _this = this;
1859+
18581860
if (!this._isDestroyed && !this.renderError) {
1859-
this.updatedCbs.push(this.scrollToAnchor);
1861+
this.updatedCbs.push(function () {
1862+
_this.scrollToAnchor();
1863+
_this.updateBarStateAndEmitEvent();
1864+
});
18601865
}
18611866
},
18621867

@@ -1943,7 +1948,7 @@ var core$1 = {
19431948
this.updateBarStateAndEmitEvent('refresh-status');
19441949
},
19451950
registryResize: function registryResize() {
1946-
var _this = this;
1951+
var _this2 = this;
19471952

19481953
/* istanbul ignore next */
19491954
if (this.destroyResize) {
@@ -1959,9 +1964,9 @@ var core$1 = {
19591964
};
19601965
var handleDomResize = function handleDomResize() {
19611966
var currentSize = {};
1962-
currentSize['width'] = _this.scrollPanelElm.scrollWidth;
1963-
currentSize['height'] = _this.scrollPanelElm.scrollHeight;
1964-
_this.updateBarStateAndEmitEvent('handle-resize', currentSize);
1967+
currentSize['width'] = _this2.scrollPanelElm.scrollWidth;
1968+
currentSize['height'] = _this2.scrollPanelElm.scrollHeight;
1969+
_this2.updateBarStateAndEmitEvent('handle-resize', currentSize);
19651970
};
19661971
window.addEventListener('resize', handleWindowResize.bind(this), false);
19671972

dist/vuescroll-native.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.

dist/vuescroll-slide.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3752,6 +3752,8 @@ var core$1 = {
37523752
_this.updatedCbs.push(function () {
37533753
_this.updateScroller();
37543754
_this.scrollToAnchor();
3755+
// Should update bar again to ensure accuracy.
3756+
_this.updateBarStateAndEmitEvent();
37553757
});
37563758
}
37573759
});

dist/vuescroll-slide.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.

dist/vuescroll.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4010,11 +4010,16 @@ function resolveOffset(mode, vm) {
40104010
var core$1 = {
40114011
mixins: [api$1, slideMix, nativeMix],
40124012
mounted: function mounted() {
4013+
var _this = this;
4014+
40134015
if (!this._isDestroyed && !this.renderError) {
40144016
if (this.mode == 'slide') {
40154017
this.updatedCbs.push(this.updateScroller);
40164018
}
4017-
this.updatedCbs.push(this.scrollToAnchor);
4019+
this.updatedCbs.push(function () {
4020+
_this.scrollToAnchor();
4021+
_this.updateBarStateAndEmitEvent();
4022+
});
40184023
}
40194024
},
40204025

@@ -4143,7 +4148,7 @@ var core$1 = {
41434148
this.updateBarStateAndEmitEvent('refresh-status');
41444149
},
41454150
registryResize: function registryResize() {
4146-
var _this = this;
4151+
var _this2 = this;
41474152

41484153
/* istanbul ignore next */
41494154
if (this.destroyResize) {
@@ -4169,17 +4174,17 @@ var core$1 = {
41694174
};
41704175
var handleDomResize = function handleDomResize() {
41714176
var currentSize = {};
4172-
if (_this.mode == 'slide') {
4173-
currentSize['width'] = _this.scroller.__contentWidth;
4174-
currentSize['height'] = _this.scroller.__contentHeight;
4175-
_this.updateBarStateAndEmitEvent('handle-resize', currentSize);
4177+
if (_this2.mode == 'slide') {
4178+
currentSize['width'] = _this2.scroller.__contentWidth;
4179+
currentSize['height'] = _this2.scroller.__contentHeight;
4180+
_this2.updateBarStateAndEmitEvent('handle-resize', currentSize);
41764181
// update scroller should after rendering
4177-
_this.updatedCbs.push(_this.updateScroller);
4178-
_this.$forceUpdate();
4179-
} else if (_this.mode == 'native') {
4180-
currentSize['width'] = _this.scrollPanelElm.scrollWidth;
4181-
currentSize['height'] = _this.scrollPanelElm.scrollHeight;
4182-
_this.updateBarStateAndEmitEvent('handle-resize', currentSize);
4182+
_this2.updatedCbs.push(_this2.updateScroller);
4183+
_this2.$forceUpdate();
4184+
} else if (_this2.mode == 'native') {
4185+
currentSize['width'] = _this2.scrollPanelElm.scrollWidth;
4186+
currentSize['height'] = _this2.scrollPanelElm.scrollHeight;
4187+
_this2.updateBarStateAndEmitEvent('handle-resize', currentSize);
41834188
}
41844189
};
41854190
window.addEventListener('resize', handleWindowResize.bind(this), false);

dist/vuescroll.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.

src/mode/mix/mixins/core.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import nativeMix from 'mode/native/mixins/update-native';
1111
function resolveOffset(mode, vm) {
1212
let axis = {};
1313
switch (mode) {
14-
case 'native':
15-
axis = {
16-
x: vm.scrollPanelElm.scrollLeft,
17-
y: vm.scrollPanelElm.scrollTop
18-
};
19-
break;
20-
case 'slide':
21-
axis = { x: vm.scroller.__scrollLeft, y: vm.scroller.__scrollTop };
22-
break;
14+
case 'native':
15+
axis = {
16+
x: vm.scrollPanelElm.scrollLeft,
17+
y: vm.scrollPanelElm.scrollTop
18+
};
19+
break;
20+
case 'slide':
21+
axis = { x: vm.scroller.__scrollLeft, y: vm.scroller.__scrollTop };
22+
break;
2323
}
2424
return axis;
2525
}
@@ -31,7 +31,10 @@ export default {
3131
if (this.mode == 'slide') {
3232
this.updatedCbs.push(this.updateScroller);
3333
}
34-
this.updatedCbs.push(this.scrollToAnchor);
34+
this.updatedCbs.push(() => {
35+
this.scrollToAnchor();
36+
this.updateBarStateAndEmitEvent();
37+
});
3538
}
3639
},
3740
computed: {

src/mode/native/mixins/core.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ export default {
66
mixins: [api, updateNative],
77
mounted() {
88
if (!this._isDestroyed && !this.renderError) {
9-
this.updatedCbs.push(this.scrollToAnchor);
9+
this.updatedCbs.push(() => {
10+
this.scrollToAnchor();
11+
this.updateBarStateAndEmitEvent();
12+
});
1013
}
1114
},
1215
methods: {

src/mode/slide/mixins/core.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export default {
1010
this.updatedCbs.push(() => {
1111
this.updateScroller();
1212
this.scrollToAnchor();
13+
// Should update bar again to ensure accuracy.
14+
this.updateBarStateAndEmitEvent();
1315
});
1416
}
1517
});

0 commit comments

Comments
 (0)