This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Javascript mouse click event
#6
Try this, but it will only work correctly if all plans have the same width:
Code:
$(function(){
  var body = $(document.body), leftEl, rightEl, timeout;

  // only apply script to user mode visualization
  if (!body.hasClass('usermode')) {
    return;
  }

  // create overlay element
  leftEl = $('<div></div>').addClass('overlay-left').appendTo(body);
  leftEl.on('vclick', function() {
    alert('clicked left');
  });

  // create overlay element
  rightEl = $('<div></div>').addClass('overlay-right').appendTo(body);
  rightEl.on('vclick', function() {
    alert('clicked right');
  });
  
  function setSize() {
    var rect = $('.layer.plan:visible').get(0).getBoundingClientRect()
        , width = Math.ceil((body.width() - rect.width) / 2);
    
    width = Math.max(0, width);
    leftEl.css('width', width);
    rightEl.css('width', width);
  }
  
  $(window).on('orientationchange resize', function() {
    clearTimeout(timeout);
    timeout = setTimeout(setSize, 150);
  });
  
  setSize();
});
Reply


Messages In This Thread
Javascript mouse click event - by Mirco - 02.11.2016, 08:33
RE: Javascript mouse click event - by admin - 02.11.2016, 09:13
RE: Javascript mouse click event - by Mirco - 02.11.2016, 09:44
RE: Javascript mouse click event - by admin - 02.11.2016, 09:48
RE: Javascript mouse click event - by Mirco - 02.11.2016, 10:38
RE: Javascript mouse click event - by admin - 02.11.2016, 11:20
RE: Javascript mouse click event - by Mirco - 02.11.2016, 12:23
RE: Javascript mouse click event - by admin - 21.11.2016, 08:18

Forum Jump: