944,208 Members | Top Members by Rank

Ad:
Feb 25th, 2007
0

Mac bar

Expand Post »
I want to do a bar with images and that each, when mouse-overed, they will grow, just like in mac os x. Very fluid.
If that can't be done, then It would also work that these images grew on mouse over, but from 20% to 100% of size. No fluid movement.

Mac os x bar:
http://youtube.com/watch?v=QBNGA_2GKdY
first seconds of video.

Also it would be cool than when clicked, they jump, just like in mac.
:cheesy:
Similar Threads
Reputation Points: 13
Solved Threads: 1
Junior Poster in Training
Racoon200 is offline Offline
66 posts
since Nov 2006
Feb 26th, 2007
0

Re: Mac bar

Do you want it to be done with JavaScript, err... i suggest flash would be better.
Reputation Points: 85
Solved Threads: 42
Nearly a Posting Virtuoso
vishesh is offline Offline
1,362 posts
since Oct 2006
Feb 26th, 2007
0

Re: Mac bar

Well, i dont know. Woudn't flash last to long to load?
I want it with javascript because then I could add icons myself. I don't have flash. I don't plan to buy it. I don't plan to take the risk of downloading it in limewire.

Thanks for the help, now...Do you know any js?
Reputation Points: 13
Solved Threads: 1
Junior Poster in Training
Racoon200 is offline Offline
66 posts
since Nov 2006
Feb 26th, 2007
0

Re: Mac bar

This is quite fun code to write. Here's an easy example; it will give a 'snapping' non fluid transition between sizes.
HTML and CSS Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function grow(what)
  5. {
  6. what.style.width="80px";
  7. what.style.height="80px";
  8. }
  9. function shrink(what)
  10. {
  11. what.style.width="50px";
  12. what.style.height="50px";
  13. }
  14. </script>
  15. <style type="text/css">
  16. td.icon_container
  17. {
  18. width:100px;
  19. height:100px;
  20. text-align:center;
  21. }
  22. img.icon
  23. {
  24. border:solid 2px black;
  25. width:50px;
  26. height:50px;
  27. }
  28. </style>
  29. </head>
  30. </body>
  31. <table class="icons">
  32. <tr>
  33. <td class="icon_container">
  34. <img class="icon" onmouseover="grow(this);" onmouseout="shrink(this);"/>
  35. </td>
  36. <td class="icon_container">
  37. <img class="icon" onmouseover="grow(this);" onmouseout="shrink(this);"/>
  38. </td>
  39. <td class="icon_container">
  40. <img class="icon" onmouseover="grow(this);" onmouseout="shrink(this);"/>
  41. </td>
  42. </tr>
  43. </table>
  44. </body>
  45. </html>

This is a nicer example. it will give a smooth adjustable slide between sizes. The code takes full advantage of javascripts 'late property binding' abilities; something I particularly like about javascript.

Both examples make use of the nature of table cells (x-y alignment) abilities. You could probably do this without tables using auto margins.

HTML and CSS Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.  
  5. /**
  6. * Change these at your will.
  7. */
  8. var SIZE_BIG = 80;
  9. var SIZE_SMALL = 40;
  10. var SIZE_INITIAL = SIZE_SMALL;
  11. var ANIM_SPEED = 5;
  12.  
  13. /**
  14. * 'Timer task' function; will keep on creating timeouts
  15. * for the parameter object until its 'present_size' and
  16. * 'go_to' properties are equal.
  17. *
  18. * \todo You should put a 'range check' rather than an
  19. * absolute zero check. You'll find, if you change the
  20. * what.present_size -= 1 and what.present_size += 1 lines
  21. * to inc/dec by 2 and then try to go to an odd numbered
  22. * size from an even numbered size, that you get a strange
  23. * vibration effect. That's why I've 'hard coded' the
  24. * inc/dec values (i.e. not made them global 'constants')
  25. */
  26. function _size(what)
  27. {
  28. if(what.present_size > what.go_to)
  29. {
  30. what.present_size -= 1;
  31. setTimeout(function(){_size(what);},ANIM_SPEED);
  32. }
  33. else if(what.present_size < what.go_to)
  34. {
  35. what.present_size += 1;
  36. setTimeout(function(){_size(what);},ANIM_SPEED);
  37. }
  38. what.style.width = what.present_size + "px";
  39. what.style.height = what.present_size + "px";
  40. }
  41. /**
  42. * Function to make sure that if a parameter object
  43. * DOESN'T yet have a runtime 'present_size' property,
  44. * that one is created and set to the initial size constant
  45. */
  46. function _size_check(what)
  47. {
  48. if(what.present_size == null)
  49. {
  50. what.present_size = SIZE_INITIAL;
  51. }
  52. }
  53. /**
  54. * Interface functions; these should be the only functions
  55. * you need to call from... 'outside' so to speak..
  56. */
  57. function grow(what)
  58. {
  59. _size_check(what);
  60. what.go_to = SIZE_BIG;
  61. _size(what);
  62. }
  63. function shrink(what)
  64. {
  65. _size_check(what);
  66. what.go_to = SIZE_SMALL;
  67. _size(what);
  68. }
  69.  
  70. </script>
  71. <style type="text/css">
  72. td.icon_container
  73. {
  74. width:100px;
  75. height:100px;
  76. text-align:center;
  77. }
  78. img.icon
  79. {
  80. border:solid 2px black;
  81. /*Should be the same as the script INITIAL_SIZE constant's value*/
  82. width:40px;
  83. height:40px;
  84. }
  85. </style>
  86. </head>
  87. </body>
  88. <table class="icons">
  89. <tr>
  90. <td class="icon_container">
  91. <img class="icon" onmouseover="grow(this);" onmouseout="shrink(this);"/>
  92. </td>
  93. <td class="icon_container">
  94. <img class="icon" onmouseover="grow(this);" onmouseout="shrink(this);"/>
  95. </td>
  96. <td class="icon_container">
  97. <img class="icon" onmouseover="grow(this);" onmouseout="shrink(this);"/>
  98. </td>
  99. </tr>
  100. </table>
  101. </body>
  102. </html>

Images are empty with borders so you can see what's going on, if you src them, then the image will scale to it's element's size.

I hope that's enough to start you making your own amusing Javscript animathingies... Code's tested on Opera 9 and Firefox 2. Let me know back if there are IE oddities...

The 'jumping' shouldn't be too hard, but it would detract from what is otherwise simple example code, so I'll leave that up to you to research...
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: Dynamic Resize DIV
Next Thread in HTML and CSS Forum Timeline: Flash Anomaly? Cannot run new image with working flash:





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC