Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a "zoom in" and "zoom out" driven by mouse scroll wheel within web pages

I'm looking for a similar experience to autocad ... or solidworks

basically the content sizes (maintaining aspect ratio) Xsize * Ysize

and magnifies particular areas

and I've included ruby / rails as my language of choice

like image 958
carl crott Avatar asked Dec 21 '25 00:12

carl crott


1 Answers

Take a look at the http://html5readiness.com/ source code. You can do exactly that in the center portion.

This is copied from Paul Irish HTML5Readiness website :

jQuery(document).bind('DOMMouseScroll mousewheel', function(e, delta) {

  var newval,
      num = $('div.css-chart p').css('padding-left');

  delta = delta || e.detail || e.wheelDelta;

  if (delta > 0 || e.which == 38) {
      newval = parseFloat(num) + 10 * (e.shiftKey ? .1 : 1);
  } else if (delta < 0 || e.which == 40) {
      newval = parseFloat(num) - 10 * (e.shiftKey ? .1 : 1);
  } else {
      return true;
  }

  $('style.padleft').remove();
  $('<style class="padleft"> div.css-chart p { padding-left : '+newval+'px; } div.css-chart p i { width : '+2*newval+'px; } </style>')
      .appendTo(document.body);

  e.preventDefault();
});
like image 51
Dominic Goulet Avatar answered Dec 23 '25 16:12

Dominic Goulet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!