summaryrefslogtreecommitdiffstats
path: root/launcher/qml/ChangeItemPosition.js
diff options
context:
space:
mode:
authorzheng_wenlong <wenlong_zheng@nexty-ele.com>2019-04-08 18:16:07 +0900
committerzheng_wenlong <wenlong_zheng@nexty-ele.com>2019-04-10 09:50:06 +0900
commit8cc6188eaf2b333e169eab6f58857adcb7e47568 (patch)
tree44084784ccee6dc136e57cc78625f9a993d12eb8 /launcher/qml/ChangeItemPosition.js
Add demo3 launcher source code for cluster mode. [Patch Set 2]Update LICENSE file. Change-Id: I9026690d30229b2587f4a6f02198cc88ba776f1d BUG-AGL: SPEC-2261 Signed-off-by: zheng_wenlong <wenlong_zheng@nexty-ele.com>
Diffstat (limited to 'launcher/qml/ChangeItemPosition.js')
-rw-r--r--launcher/qml/ChangeItemPosition.js89
1 files changed, 89 insertions, 0 deletions
diff --git a/launcher/qml/ChangeItemPosition.js b/launcher/qml/ChangeItemPosition.js
new file mode 100644
index 0000000..9fae07c
--- /dev/null
+++ b/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
+ }
+}