1

I am trying to create a menu just like Windows 8 Start Menu (Metro style) using JQuery Mobile.

I'm going to use JQuery Mobile Scrollview for this purpose. (see this example)

Scrollview adds elemets by Horizontal order (like the image below)

Current Above image is real screenshot

But I want to add elemets to the Scrollview by vertical order (like the image below)

Goal Above Image is NOT real. It's my goal. (I have created it in MS Paint :P )

So, my question is: How to change adding order of the Scrollview to vertical order? (like the second image)

Mahdi Ghiasi
  • 14,873
  • 19
  • 71
  • 119

1 Answers1

1

In agreement with this POST

you should move items on the list in order to reorder the desired sequence (eg translation matrices), once you get what you can eliminate the above list and recreate it again, after which the mobile jquery apply its effects.

I tried this (using your example, i've copied the page on local), it is not nice but you get the idea.

<script>

$(document).ready(function(){


var arr = $.map( $(".threeByThree").children().text(), function(n){
   return n;
 });

var result = [];
var results;

while(arr.length){

    transform(arr.splice(0,8));     
}   

function transform(arr){

    var a = [
        [arr[0], arr[1], arr[2]],
        [arr[3], arr[4], arr[5]],
        [arr[6], arr[7], arr[8]]
    ],

    w = a.length ? a.length : 0,
    h = a[0] instanceof Array ? a[0].length : 0;

  if(h === 0 || w === 0) { return []; }

  var i, j, t = [];

  for(i=0; i<h; i++) {

    t[i] = [];

    for(j=0; j<w; j++) {

       t[i][j] = a[j][i];
    }
  }

results = result += t;
result += t; 

var rm = ',';

results = $.grep(results, function(value) {
  return value != rm;
});

}

$('.threeByThree').children().remove();

$.each(results, function(index, value){$('.threeByThree').append('<div class="square">'+value+'</div>');

});

});

</script>

and

.threeByThree > .ui-scrollview-view {
    height: 300px;
    background-color: white;
}

is just a test to improve.

Community
  • 1
  • 1
Alex Ball
  • 4,404
  • 2
  • 17
  • 23
  • I'm sorry, but I'm getting an empty scrollview using your code ( see this : http://i.imgur.com/kADJF.png ) Can you apply your changes to this file ( http://pastie.org/4043814 ) and send me the changed file? Thanks. – Mahdi Ghiasi Jun 07 '12 at 11:44
  • I'm sorry, but please use **horizontal** scrollview instead of vertical scrollview in your example. Thanks. – Mahdi Ghiasi Jun 07 '12 at 21:46
  • @Mahdi, the example is one way (bad) to change the order of items, then I think you can appilcare other effects. I know jQuery Mobile, and the scroll does not work locally. This is the example I wanted to change order factors [Fiddle](http://jsfiddle.net/ukfCD/) – Alex Ball Jun 08 '12 at 07:06
  • Since I'm using a programming language (ASP.NET or PHP) to download RSS feeds, I think I also should make elements in the right order using ASP.NET or PHP. What do you think? – Mahdi Ghiasi Jun 08 '12 at 07:35