252
253
property real iconsDisabledOpacity: 0.3
254
property bool hoveringLeft: false
255
property bool hoveringRight: false
257
function checkHovering(mouse) {
258
if (mouse.x < listViewContainer.listViewMargins) {
259
if (!hoveringLeft) hoveringLeft = true;
260
} else if (mouse.x > width - listViewContainer.listViewMargins) {
261
if (!hoveringRight) hoveringRight = true;
263
hoveringLeft = false;
264
hoveringRight = false;
268
255
anchors.fill: parent
269
256
hoverEnabled: true
271
onPositionChanged: checkHovering(mouse)
273
hoveringLeft = false;
274
hoveringRight = false;
258
property bool pressedLeft: false
259
property bool pressedRight: false
277
if (!hoveringLeft && !hoveringRight) {
278
mouse.accepted = false;
261
pressedLeft = leftIcon.contains(mouse);
262
pressedRight = rightIcon.contains(mouse);
263
mouse.accepted = pressedLeft || pressedRight;
282
266
// positionViewAtIndex() does not provide animation
267
var scrollDirection = 0;
268
if (pressedLeft && leftIcon.contains(mouse)) {
269
scrollDirection = -1;
270
} else if (pressedRight && rightIcon.contains(mouse)) {
273
// User pressed on the left or right icon, and then released inside of the
274
// MouseArea but outside of the icon that was pressed.
283
277
if (contentXAnim.running) contentXAnim.stop();
284
var newContentX = sectionsListView.contentX + (sectionsListView.width * (hoveringLeft ? -1 : 1));
278
var newContentX = sectionsListView.contentX + (sectionsListView.width * scrollDirection);
285
279
contentXAnim.from = sectionsListView.contentX;
286
280
// make sure we don't overshoot bounds
287
281
contentXAnim.to = MathUtils.clamp(
289
sectionsListView.originX,
283
0.0, // estimation of originX is some times wrong when scrolling towards the beginning
290
284
sectionsListView.originX + sectionsListView.contentWidth - sectionsListView.width);
291
285
contentXAnim.start();
290
objectName: "left_scroll_icon"
291
// return whether the pressed event was done inside the area of the icon
292
function contains(mouse) {
293
return (mouse.x < listViewContainer.listViewMargins &&
294
!sectionsListView.atXBeginning);
297
297
left: parent.left
298
298
leftMargin: (listViewContainer.listViewMargins - width) / 2
318
id: rightHoveringIcon
319
objectName: "right_scroll_icon"
320
// return whether the pressed event was done inside the area of the icon
321
function contains(mouse) {
322
return (mouse.x > (hoveringArea.width - listViewContainer.listViewMargins) &&
323
!sectionsListView.atXEnd);
320
326
right: parent.right
321
327
rightMargin: (listViewContainer.listViewMargins - width) / 2
387
393
when: hoveringArea.containsMouse
388
394
PropertyChanges { target: mask; visible: true }
389
395
PropertyChanges { target: listViewContainer; opacity: 0.0 }
390
PropertyChanges { target: leftHoveringIcon; visible: true; }
391
PropertyChanges { target: rightHoveringIcon; visible: true; }
396
PropertyChanges { target: leftIcon; visible: true; }
397
PropertyChanges { target: rightIcon; visible: true; }