mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
widgets: stop inertia with mouse wheel completely
This commit is contained in:
@@ -29,6 +29,7 @@ Flickable {
|
||||
property real lastWheelTime: 0
|
||||
property real momentum: 0
|
||||
property var velocitySamples: []
|
||||
property bool sessionUsedMouseWheel: false
|
||||
|
||||
function startMomentum() {
|
||||
flickable.isMomentumActive = true
|
||||
@@ -49,10 +50,12 @@ Flickable {
|
||||
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0
|
||||
|
||||
if (isMouseWheel) {
|
||||
sessionUsedMouseWheel = true
|
||||
momentumTimer.stop()
|
||||
flickable.isMomentumActive = false
|
||||
velocitySamples = []
|
||||
momentum = 0
|
||||
flickable.momentumVelocity = 0
|
||||
|
||||
const lines = Math.floor(Math.abs(deltaY) / 120)
|
||||
const scrollAmount = (deltaY > 0 ? -lines : lines) * flickable.mouseWheelSpeed
|
||||
@@ -65,6 +68,7 @@ Flickable {
|
||||
|
||||
flickable.contentY = newY
|
||||
} else {
|
||||
sessionUsedMouseWheel = false
|
||||
momentumTimer.stop()
|
||||
flickable.isMomentumActive = false
|
||||
|
||||
@@ -111,7 +115,7 @@ Flickable {
|
||||
|
||||
onActiveChanged: {
|
||||
if (!active) {
|
||||
if (Math.abs(flickable.momentumVelocity) >= flickable.minMomentumVelocity) {
|
||||
if (!sessionUsedMouseWheel && Math.abs(flickable.momentumVelocity) >= flickable.minMomentumVelocity) {
|
||||
startMomentum()
|
||||
} else {
|
||||
velocitySamples = []
|
||||
|
||||
@@ -33,6 +33,7 @@ GridView {
|
||||
property real lastWheelTime: 0
|
||||
property real momentum: 0
|
||||
property var velocitySamples: []
|
||||
property bool sessionUsedMouseWheel: false
|
||||
|
||||
function startMomentum() {
|
||||
isMomentumActive = true
|
||||
@@ -52,10 +53,12 @@ GridView {
|
||||
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0
|
||||
|
||||
if (isMouseWheel) {
|
||||
sessionUsedMouseWheel = true
|
||||
momentumTimer.stop()
|
||||
isMomentumActive = false
|
||||
velocitySamples = []
|
||||
momentum = 0
|
||||
momentumVelocity = 0
|
||||
|
||||
const lines = Math.floor(Math.abs(deltaY) / 120)
|
||||
const scrollAmount = (deltaY > 0 ? -lines : lines) * cellHeight * 0.35
|
||||
@@ -68,6 +71,7 @@ GridView {
|
||||
|
||||
contentY = newY
|
||||
} else {
|
||||
sessionUsedMouseWheel = false
|
||||
momentumTimer.stop()
|
||||
isMomentumActive = false
|
||||
|
||||
@@ -108,7 +112,7 @@ GridView {
|
||||
}
|
||||
onActiveChanged: {
|
||||
if (!active) {
|
||||
if (Math.abs(momentumVelocity) >= minMomentumVelocity) {
|
||||
if (!sessionUsedMouseWheel && Math.abs(momentumVelocity) >= minMomentumVelocity) {
|
||||
startMomentum()
|
||||
} else {
|
||||
velocitySamples = []
|
||||
|
||||
@@ -50,6 +50,7 @@ ListView {
|
||||
property real lastWheelTime: 0
|
||||
property real momentum: 0
|
||||
property var velocitySamples: []
|
||||
property bool sessionUsedMouseWheel: false
|
||||
|
||||
function startMomentum() {
|
||||
isMomentumActive = true
|
||||
@@ -71,10 +72,12 @@ ListView {
|
||||
const isMouseWheel = Math.abs(deltaY) >= 120 && (Math.abs(deltaY) % 120) === 0
|
||||
|
||||
if (isMouseWheel) {
|
||||
sessionUsedMouseWheel = true
|
||||
momentumTimer.stop()
|
||||
isMomentumActive = false
|
||||
velocitySamples = []
|
||||
momentum = 0
|
||||
momentumVelocity = 0
|
||||
|
||||
const lines = Math.floor(Math.abs(deltaY) / 120)
|
||||
const scrollAmount = (deltaY > 0 ? -lines : lines) * mouseWheelSpeed
|
||||
@@ -89,6 +92,7 @@ ListView {
|
||||
listView.contentY = newY
|
||||
savedY = newY
|
||||
} else {
|
||||
sessionUsedMouseWheel = false
|
||||
momentumTimer.stop()
|
||||
isMomentumActive = false
|
||||
|
||||
@@ -138,7 +142,7 @@ ListView {
|
||||
onActiveChanged: {
|
||||
if (!active) {
|
||||
isUserScrolling = false
|
||||
if (Math.abs(momentumVelocity) >= minMomentumVelocity) {
|
||||
if (!sessionUsedMouseWheel && Math.abs(momentumVelocity) >= minMomentumVelocity) {
|
||||
startMomentum()
|
||||
} else {
|
||||
velocitySamples = []
|
||||
|
||||
Reference in New Issue
Block a user