Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Mouse Scrolling #645

Open
Oneil974 opened this issue Jul 24, 2017 · 1 comment
Open

Disable Mouse Scrolling #645

Oneil974 opened this issue Jul 24, 2017 · 1 comment
Labels
enhancement javascript Pull requests that update Javascript code map viewer

Comments

@Oneil974
Copy link

Oneil974 commented Jul 24, 2017

Hi,

As suggered by @mdouchin it could be interesting to add an option for disable mouse scrolling on map in lizmap plugin.

Actually I'm using this JS code in repo.

lizMap.events.on({
   uicreated: function(e) {
      $('#map').bind('mousewheel DOMMouseScroll', function(event){ return false});
   }
});
@rmarzocchi84
Copy link
Contributor

I customize the javascript adding the following options:

  • disable mouse scrolling only for iframe map if (window !== window.parent){ }
  • use the ctrl to scroll (like google) if (event.type==='mousewheel' && event.ctrlKey === false){}
  • add modal to explain how to use the scroll
function testConfirm() {

  var $dialog = $('<div></div>')
    .html("EXPLICATION HOW TO USE SCROLL")  //need to be translated 
    .dialog({
      resizable: false,
      title: "Nota bene",
      modal: true,
      buttons: {
        /*Cancel: function() {
          $(this).dialog("close");
        },*/
        "Close": function() {
          //some stuff
          $(this).dialog("close");
        }
      }
    });

  $dialog.dialog('open');
}




lizMap.events.on({
   uicreated: function(e) {
		$('#map').bind('mousewheel', function(event){	
			//se sono in un iframe window.frameElement è != null quindi entro qua dentro, altrimenti no e la mappa si comporta come al solito
			//if (window.frameElement){
			if (window !== window.parent){ 
				if (event.type==='mousewheel'  && event.ctrlKey === false){
					//console.log(window.frameElement);
					console.log('window');
					console.log(window);
					console.log('window.parent');
					console.log(window.parent);
					console.log(event.type);
					//console.log(mouseWheelZoom);
					//$('#map').popover('show');
					testConfirm();
					//alert('Per lo scroll sulla pagina effettuare lo scroll al di fuori della mappa, per effettuare lo zoom della mappa tenere premuto il tasto CTRL');
					return false;
					//return platformModifierKeyOnly(event);
				} else 
				//if(event.ctrlKey === true)
				{
					console.log(event.originalEvent.detail);
					//event.preventDefault();
					if(event.originalEvent.detail > 0) {
						console.log('OK');
						alert('Per lo zoom tenere premuto il tasto CTRL');
						return false;
					 }else {
						console.log('Up');
						//return alert('Per lo zoom tenere premuto il tasto CTRL');
					 }
					return true; 
				}
			} // fine check iframe	
		});
			
   }  
});

I hope it can be useful for further integration in the main code. Let me know if I can do more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement javascript Pull requests that update Javascript code map viewer
Projects
None yet
Development

No branches or pull requests

4 participants