Guest User

Untitled

a guest
Feb 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. // Mark things you want to resize with class="resizeable"
  2. // The ratio between their sizes will be maintained.
  3. // works with jquery-1.4.2.min.js
  4. //
  5. // <script src=".../jquery-1.4.2.min.js"></script>
  6. // <script src=".../resize.js"></script>
  7. //
  8.  
  9.  
  10. function resizeNodes(nodes, startsizes, multiplier){
  11. var newsizes = startsizes.map(function(item, index){return item * multiplier;});
  12. nodes.each(function(index){$(this).css('font-size',newsizes[index]);});
  13. };
  14.  
  15. function resize() {
  16. var multiplier = 1.0;
  17. var nodes = $(".resizeable");
  18. var startsizes = nodes.map(function(){return parseFloat($(this).css('font-size'),10);}).get();
  19.  
  20. while ($(document).height()<=($(window).height()))
  21. {
  22. multiplier += 0.5;
  23. resizeNodes(nodes, startsizes, multiplier);
  24. };
  25. while ($(window).height()<$(document).height()&& multiplier > 0.5)
  26. {
  27. multiplier -= 0.01;
  28. resizeNodes(nodes, startsizes, multiplier);
  29. };
  30. while ($(window).width()<$(document).width() && multiplier > 0.5)
  31. {
  32. multiplier -= 0.05;
  33. resizeNodes(nodes, startsizes, multiplier);
  34. };
  35. };
  36.  
  37. $(document).ready(resize);
Add Comment
Please, Sign In to add comment