From b698c64694179d0c2f634d4d35eab803158b4eaa Mon Sep 17 00:00:00 2001 From: zheng_wenlong Date: Wed, 14 Nov 2018 12:36:02 +0900 Subject: Add launcher for horizontal mode Add launcher for horizontal mode. Change-Id: I2a34b606c8f97fc30f43fe95427d5392edc57c2a Signed-off-by: zheng_wenlong --- .../launcher/launcher/qml/ChangeItemPosition.js | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 demo3/horizontal/launcher/launcher/qml/ChangeItemPosition.js (limited to 'demo3/horizontal/launcher/launcher/qml/ChangeItemPosition.js') diff --git a/demo3/horizontal/launcher/launcher/qml/ChangeItemPosition.js b/demo3/horizontal/launcher/launcher/qml/ChangeItemPosition.js new file mode 100644 index 0000000..9fae07c --- /dev/null +++ b/demo3/horizontal/launcher/launcher/qml/ChangeItemPosition.js @@ -0,0 +1,89 @@ +function next() { + repeater.currentItem += 1; + if (repeater.currentItem > repeater.count - 1) + { + repeater.currentItem = 0; + } + var count = 0; + + for (var i = 0; i < repeater.count; i++) + { + var item = repeater.itemAt(i); + item.currentState -= 1; + if ( item.currentState < 1 ) + { + item.currentState = repeater.count; + } + if ( item.currentState >= 1 && item.currentState <= 10 ) + { + item.state = "pos" + item.currentState + } else if ( item.currentState === 15 ){ + item.state = "pos11"; + } else if ( item.currentState === 16 ){ + item.state = "pos12"; + } else if ( item.currentState === 17 ){ + item.state = "pos13"; + } else if ( item.currentState >= 18 ){ + item.state = "pos0"; + } else { + item.state = "pos10"; + } + } +} + +function prev() { + repeater.currentItem -= 1; + if (repeater.currentItem < 0) + { + repeater.currentItem = repeater.count - 1; + } + var count = repeater.count; + for (var i = 0; i < repeater.count; i++) + { + var item = repeater.itemAt(i); + item.currentState += 1; + if ( item.currentState > repeater.count ) + { + item.currentState = 1; + } + if ( item.currentState >= 1 && item.currentState <= 10 ) + { + item.state = "pos" + item.currentState + } else if ( item.currentState === 15 ){ + item.state = "pos11"; + } else if ( item.currentState === 16 ){ + item.state = "pos12"; + } else if ( item.currentState === 17 ){ + item.state = "pos13"; + } else if ( item.currentState >= 18 ){ + item.state = "pos0"; + } else { + item.state = "pos10"; + } + } +} + +function move(pos, item) { + var distance = firstPox - pos; + if(distance > 200) { + next() + firstPox = pos + iconMoved = true + item.iconReleased() + } else if (distance < -200) { + prev() + firstPox = pos + iconMoved = true + item.iconReleased() + } +} + +function getCenterItem() { + var item; + for (var i = 0; i < repeater.count; i++) + { + item = repeater.itemAt(i) + if (item.state === "pos5" || item.state === "pos14") + return item + } +} -- cgit 1.2.3-korg