Skip to content

Commit 4c52e5c

Browse files
committed
feat(QScrollArea): New method -> setScrollPercentage quasarframework#7696
1 parent 10291ab commit 4c52e5c

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

ui/dev/src/pages/components/scroll-area.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@
5757
<q-btn @click="scroll2">
5858
Scroll to 525 (animated)
5959
</q-btn>
60+
<q-btn @click="scroll3">
61+
Scroll to 90%
62+
</q-btn>
6063

6164
<div style="height: 1000px" />
6265
</div>
@@ -105,6 +108,9 @@ export default {
105108
},
106109
scroll2 () {
107110
this.$refs.scroll.setScrollPosition(525, 1000)
111+
},
112+
scroll3 () {
113+
this.$refs.scroll.setScrollPercentage(0.9, 1000)
108114
}
109115
}
110116
}

ui/src/components/scroll-area/QScrollArea.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ export default Vue.extend({
158158
fn(this.$refs.target, offset, duration)
159159
},
160160

161+
setScrollPercentage (percentage, duration) {
162+
this.setScrollPosition(
163+
percentage * (this.scrollSize - this.containerSize),
164+
duration
165+
)
166+
},
167+
161168
__updateContainer ({ height, width }) {
162169
let change = false
163170

ui/src/components/scroll-area/QScrollArea.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,24 @@
161161
"examples": [ 300 ]
162162
}
163163
}
164+
},
165+
166+
"setScrollPercentage": {
167+
"desc": "Set scroll position to a percentage (0.0 < x < 1.0) of the total scrolling size; If a duration (in milliseconds) is specified then the scroll is animated",
168+
"params": {
169+
"offset": {
170+
"type": "Number",
171+
"desc": "Scroll percentage (0.0 < x < 1.0) of the total scrolling size",
172+
"required": true,
173+
"examples": [ 220 ]
174+
},
175+
"duration": {
176+
"type": "Number",
177+
"desc": "Duration (in milliseconds) enabling animated scroll",
178+
"examples": [ 300 ]
179+
}
180+
},
181+
"addedIn": "v1.13.2"
164182
}
165183
}
166184
}

0 commit comments

Comments
 (0)