Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Scrolling
Hi,
 
I have a scrollTop() function in a jquery method that scrolls an element to the desired position based on the mouse movement.
 
This function always worked perfectly until I decided to remove the height of the element. By removing the height of the element, the element height is determined by the amount of tds (rows) in the element. Before the height was preset to 200px, now it works fine because some elements are 178px and others are 348px in height!
 
Why won't the scrolltop() function work now though? I am following the scrollTop line with breakpoints and the values are being computed perfectly but the element simply refuses to move down or up.
 
Thanks a lot,
Justin
Posted 21-Apr-13 6:48am
Jukatzu297
Comments
abforce at 21-Apr-13 11:54am
   
please attach some codes that tried with it / explain more with your codes
Jukatzu at 21-Apr-13 11:57am
   
Hi abforce,
 
info-col used to be the one commented, now its the one beneath it:
 
/*.info-col { float: left; width: 0px; height: 200px; padding: 0px 0 0 0; overflow:hidden;}*/
.info-col { float: left; width: 0px; padding: 0px 0 0 0; overflow:hidden;}
 

jquery scrolltop function:
 
$(".info-col").mousemove(function (mouse) {
$(".info-col").scrollTop((mouse.pageY - $(".info-col").offset().top) * .81);
})
 
Thanks a lot for your quick reply. If you need anything else please tell me.
Justin
abforce at 21-Apr-13 12:04pm
   
sorry my friend , i cannot figure out the problem, are you want to create a scrollbar for your info-col ??
Jukatzu at 21-Apr-13 12:06pm
   
Yes, the scrolling occurs by getting the mouse Y position and scrolls the element relative to that. Now that used to work fine before I removed the height 200px as you see from above. What isn't it anymore?
abforce at 21-Apr-13 12:10pm
   
if you just want to put a scrollbar to the info-col , you can set overflow:scrollbar in it's css
Jukatzu at 21-Apr-13 12:11pm
   
I know that. Thank you. I just want to find out why removing the height prevents it from working. Thanks again for your help abforce.
abforce at 21-Apr-13 12:14pm
   
if you omit height in css , it initialize with value 'auto' then you cannot have some calculate with this value unless the html element to be in absolute position. ok ?
Jukatzu at 21-Apr-13 12:20pm
   
hmmm I see, so that explains it, great. How can I then make the element height based on the amount of items inside it? Let's say current info-col has 10 items, so height is 200. info-col next to it has 3 items so height needs to be 60 only!
 
I don't want the element height to be fixed and position has to be relative. Is there a way?
abforce at 21-Apr-13 12:24pm
   
Sorry my dear , i don't know . try by googeling
Jukatzu at 21-Apr-13 12:25pm
   
thank you, your explanation has mattered a lot though ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 175
1 Kornfeld Eliyahu Peter 169
2 Zoltán Zörgő 139
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 21 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100