/    Sign up×
Community /Pin to ProfileBookmark

how to block the blocks from moving up?

Hi guys,

I have the list of rows with 7 blocks where the other blocks are hiding. I have 7 blocks which is showing from block 1 to block 7. When I press on the down arrow button of the keyboard, the blocks will moving up using ‘rowheight’ which it looks good to go, but there is a problem. When I press on the down arrow button until when the yellow block get on the end of the block, e.g.: block 11. When I press on the up arrow button quite few times, the blocks will move down without have any problem. When I try to press on the down button to get back to the block 11, the blocks supposed to stay where they are without moving up until the yellow block goes after the block 11 then move the blocks up, but the blocks will move up when I’m on the block 9. The same things it goes for other blocks.

I think the problem are somewhere in this code:

[ICODE] if (event.keyCode == 38)
{ //up
if(current_col > 1 && current_row == 1)
{
var currentrowtop = $(“.mainWrap div.row:first-child”).css( “margin-top”);

var calcuatedrowtop = -(current_col*rowheight);
currentrowtop = parseInt(currentrowtop)-rowheight;

if((currentrowtop – calcuatedrowtop) < rowheight)
{
currentrowtop = parseInt(currentrowtop)+rowheight;
currentrowtop = parseInt(currentrowtop)+rowheight;
var rowtop = currentrowtop+=”px”;
$(“.mainWrap div.row:first-child”).css( “margin-top”, rowtop );
}
current_col–;
}
}
else if (event.keyCode == 40)
{ //down
if(current_col < totalrowcount && current_row == 1)
{
if(current_col >= displayrowcount)
{
var currentrowtop = $(“.mainWrap div.row:first-child”).css( “margin-top”);
currentrowtop = parseInt(currentrowtop)-rowheight;
var rowtop = currentrowtop+=”px”;
$(“.mainWrap div.row:first-child”).css( “margin-top”, rowtop );
}
current_col++;
}
}[/ICODE]

In this case, when I press on the down arrow button from block 1 to block 7 and if I press on the up arrow button, the blocks will not move up where it stays on. When I press on the down arrow button to get on the block 9, if I press on the up arrow button few times and then the down arrow button to get back to the block 9 which it come after the block 8, the blocks will move up when I am on the middle of the blocks that I want to get to the block 9 without the blocks get moving. I want the blocks to stay where they are without get moving to allow me to get back to the block 9. The same things it goes for other blocks. I want the blocks to move up only when I’m after the end of the block beside the hiding blocks, e.g.: block 9. The block after the block 9 is the block 10 so I want to move them up when I’m on the block 10, block 11 and so on. I don’t want the blocks to move up when I’m on the middle of the block even when I’m not on the end of the block.

Does anyone know how I can block the blocks from moving up when I’m on the middle of the block to allow me to get on to each block until the end of the block, e.g block 11 then move the block 12 up and so on?

Here’s the jsfiddle if you need to take a look: [url]http://jsfiddle.net/VZWNE/13/[/url]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @mark107 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...