mattbryson / TouchSwipe-Jquery-Plugin

TouchSwipe is a jquery plugin to be used with jQuery on touch input devices such as iPad, iPhone etc.
http://labs.rampinteractive.co.uk/touchSwipe/
Other
4.05k stars 1.68k forks source link

Maintain state of last pinchZoom value #287

Closed kumarkratigwithme closed 6 years ago

kumarkratigwithme commented 8 years ago

Hello, I am using swipe and pinchZoom, here is my sample code- $("#styleProfileListUnlocked").swipe( { swipeStatus:function(event, phase, direction, distance , duration , fingerCount) {

       console.log("swiped " + distance + ' px');
       if(direction=="right"){
       $('#userActualPic').css({'left':''+distance+'px'}); 
       }
       if(direction=="left"){
       $('#userActualPic').css({'left':'-'+distance+'px'}); 
       }
       if(direction=="down"){
       $('#userActualPic').css({'top':''+distance+'px'}); 
       }
       if(direction=="up"){
       $('#userActualPic').css({'top':'-'+distance+'px'}); 
       }

       if(phase === $.fn.swipe.phases.PHASE_END || phase === $.fn.swipe.phases.PHASE_CANCEL) {
         //The handlers below fire after the status, 
         // so we can change the text here, and it will be replaced if the handlers below fire
         console.log("No swipe was made");
       }
    },
    pinchStatus:function(event, phase, direction, distance , duration , fingerCount, pinchZoom) {
      $(this).find('#pinch_text').text("pinched " + distance + " px ");

      $('#userActualPic').css('transform','scale('+pinchZoom+')');

      if(phase === $.fn.swipe.phases.PHASE_END || phase === $.fn.swipe.phases.PHASE_CANCEL) {
         //The handlers below fire after the status, 
         // so we can change the text here, and it will be replaced if the handlers below fire
         console.log("No pinch was made");
       }
    },
    swipe:function(event, direction, distance, duration, fingerCount) {
       console.log("You swiped " + direction + " with " + fingerCount + " fingers");
    },
    pinchIn:function(event, direction, distance, duration, fingerCount, pinchZoom) {
      console.log("You pinched " +direction + " by " + distance +"px, zoom scale is "+pinchZoom); 
    },
    pinchOut:function(event, direction, distance, duration, fingerCount, pinchZoom) {
      console.log("You pinched " +direction + " by " + distance +"px, zoom scale is "+pinchZoom);
    },
    fingers:$.fn.swipe.fingers.ALL,
    threshold:20  
  });

Use case- Pinch to zoom, swipe to change position and when again try to pinchZoom, initial pinchZoom is set to 1, which makes my div again scale to zero. How maintain the last zoom state. Also there is flicker when I try to move from left-center-right position. Any help will be really helpful!!

Cheers

mattbryson commented 6 years ago

Closing as over a year old. Please feel free to re open if you are still having issues.