sonics876
sonics876

Reputation: 957

jQTouch disable scrolling, enable scrolling, to disable scrolling

I'm working with jQTouch and I'm using the animations to link to different href #ids on the same page. On some pages I would want to disable scrolling, and others I want to enable scrolling. By setting disabled scrolling onload then enabling it onlick to another id it will work. However, I cannot switch back to disabled scrolling. Any ideas?

function e(){ document.ontouchmove = function(event){ } } function d(){ document.ontouchmove = function(event){ event.preventDefault(); } }

Upvotes: 0

Views: 3073

Answers (3)

Mohammadreza Yektamaram
Mohammadreza Yektamaram

Reputation: 1502

You can use this code to disable mouse move:

   $(document).bind("touchmove",function(event){
    event.preventDefault();
   });

Upvotes: 1

JohnZ
JohnZ

Reputation: 11

$('#dont_move')[0].addEventListener('touchmove', function(e){ e.preventDefault(); }, false);

Upvotes: 1

Kris Erickson
Kris Erickson

Reputation: 33834

Turn the move off by the div. For example:

<div id="dont_move">
   <ul>
      <li>Item 1</li>
      <li>Item 2</li>
   </ul>
<div id="scroll_me">
   <ul>
      <li>Item 1</li>
      <li>Item 2</li>
      <li>Item 3</li>
      <li>Item 4</li>
      <li>Item 5</li>
      <li>Item 6</li>
      <li>Item 7</li>
      <li>Item 8</li>
      <li>Item 9</li>
      <li>Item 10</li>
      <li>Item 11</li>
      <li>Item 12</li>
   </ul>
</div>

And then in your script add:

$('#dont_move')[0].addEventListener('touchmove', function(e){ e.preventDefault(); });    

Upvotes: 1

Related Questions