summaryrefslogtreecommitdiffstats
path: root/launcher/qml/ChangeItemPosition.js
blob: 9fae07c5b359784c0d021b038ca86c83302309a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* 
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
    }
}