简体   繁体   English

在下拉菜单上滚动时如何防止身体滚动?

[英]How to prevent body scrolling when scroll on Drop down menu.?

How to prevent body scrolling when scroll on Drop down menu.? 在下拉菜单上滚动时如何防止身体滚动? 1 1

Dear friends, 亲爱的朋友们,

actually i'm facing problem in my project. 实际上我在项目中面临问题。 see project 见项目

i did horizontal scrolling on this page. 我在此页面上进行了水平滚动。 its is working smoothly. 它工作顺利。 but when i scroll on drop down menu the page also scrolling. 但是当我在下拉菜单上滚动时,页面也会滚动。 is there any option to prevent the page scrolling when mouse hover in drop down menu? 鼠标悬停在下拉菜单中时,有什么选项可以防止页面滚动?

adding the script here which i used for horizontal scroll: 在此处添加用于水平滚动的脚本:

<script type="text/javascript">

// By default, swipe is enabled.

 $('section').horizon();

 // If you do not want to include another plugin, TouchSwipe, you can set it to false in the default options by passing in the option as false.
 //$('section').horizon({swipe: false});

 $(document).on('click', '.go-to-2', function () {
    $(document).horizon('scrollTo', 'section-section2');
 });
</script> 

please help me to find out Any solution... 请帮助我找出任何解决方案...

If you want to prevent the text area below Emporio Kannur... from scrolling, try adding a mousewheel event listener and stop event propagation, so it does not bubble up to the horizon jquery plugin. 如果要防止Emporio Kannur...下面的文本区域滚动,请尝试添加mousewheel事件侦听器并停止事件传播,以使它不会出现在horizon jquery插件上。

Something like this: 像这样:

// .work_detail_wraper contains the text you down want to see scrolling
$('.work_detail_wraper') 
  .on('mousewheel DOMMouseScroll' , function(e) { 
     e.stopPropagation() 
  })

You can also take a look at the horizon plugin's code , and adapt it so it doesn't scroll on certain events. 您还可以查看一下Horizo​​n插件的代码 ,并对其进行调整,以使其在某些事件下不会滚动。

You can use 'stopPropagation()' for this 您可以为此使用“ stopPropagation()”

$('.section-section2').scroll(function(e){
    e.stopPropagation();
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM