/dev/adei-asec

To get this branch, use:
bzr branch http://darksoft.org/webbzr/dev/adei-asec

« back to all changes in this revision

Viewing changes to includes/cropper/cropper.js

  • Committer: Suren A. Chilingaryan
  • Date: 2010-08-04 06:30:21 UTC
  • Revision ID: csa@dside.dyndns.org-20100804063021-shdx01q2pg5r3a1k
Initial commit of gestures support for iDevices by Toni Pirhonen, Fix IE support broken by revision r196

Show diffs side-by-side

added added

removed removed

Lines of Context:
286
286
                                 * The call back function on mouse moving
287
287
                                 */
288
288
                                 onMouseMove: null,
 
289
                                 
 
290
 
 
291
                                 onTouchStart: null,
 
292
                                 onTouchMove: null,
 
293
                                 onTouchEnd: null,
 
294
                                 onGestureStart: null,
 
295
                                 onGestureMove: null,
 
296
                                 onGestureEnd: null,
 
297
                                 onOrientationChange: null,
 
298
          
289
299
                                /**
290
300
                                 * @var function
291
301
                                 * The call back function to pass the final values to
735
745
                    this.onMouseMoveBind        = this.onMouseMove.bindAsEventListener( this );
736
746
                    Event.observe( this.dragArea, 'mousemove', this.onMouseMoveBind );
737
747
                    this.onMouseOutBind         = this.onMouseOut.bindAsEventListener( this );
738
 
                    Event.observe( this.dragArea, 'mouseout', this.onMouseOutBind );
 
748
                    Event.observe( document, 'mouseout', this.onMouseOutBind );
739
749
                }
740
 
                
 
750
 
 
751
    if(this.options.onTouchStart){
 
752
      this.onTouchStartBind = this.onTouchStart.bindAsEventListener(this);
 
753
      Event.observe(this.dragArea,'touchstart',this.onTouchStartBind);
 
754
    }
 
755
    if(this.options.onTouchMove){
 
756
      this.onTouchMoveBind = this.onTouchMove.bindAsEventListener(this);
 
757
      Event.observe(this.dragArea,'touchmove',this.onTouchMoveBind);
 
758
    }
 
759
    if(this.options.onTouchEnd){
 
760
      this.onTouchEndBind = this.onTouchEnd.bindAsEventListener(this);
 
761
      Event.observe(this.dragArea, 'touchend',this.onTouchEndBind);
 
762
    }
 
763
    if(this.options.onGestureStart){
 
764
      this.onGestureStartBind = this.onGestureStart.bindAsEventListener(this);
 
765
      Event.observe(this.dragArea,'gesturestart',this.onGestureStartBind);
 
766
    }
 
767
    if(this.options.onGestureMove){
 
768
      this.onGestureMoveBind = this.onGestureMove.bindAsEventListener(this);
 
769
      Event.observe(this.dragArea,'gesturechange',this.onGestureMoveBind);
 
770
    }
 
771
    if(this.options.onGestureEnd){
 
772
      this.onGestureEndBind = this.onGestureEnd.bindAsEventListener(this);
 
773
      Event.observe(this.dragArea,'gestureend',this.onGestureEndBind);
 
774
    }
 
775
    if(this.options.onOrientationChange){
 
776
      this.onOrientationChangeBind = this.onOrientationChange.bindAsEventListener(this);
 
777
      Event.observe(this.dragArea,'orientationchange',this.onOrientationChangeBind);
 
778
    }
 
779
 
 
780
 
741
781
                this.endCropBind        = this.endCrop.bindAsEventListener( this );
742
782
                Event.observe( document, 'mouseup', this.endCropBind );
743
783
//              Event.observe( this.imgWrap, 'mouseup', this.endCropBind );
914
954
                            Event.stopObserving( document, 'mousemove', this.onMouseMoveBind );         
915
955
                            Event.stopObserving( document, 'mouseout', this.onMouseOutBind );           
916
956
                        }
 
957
 
 
958
            if(this.options.onTouchStart){
 
959
                Event.stopObserving(this.dragArea,'touchstart',this.onTouchStartBind);
 
960
            }
 
961
            if(this.options.onTouchMove){
 
962
              Event.stopObserving(this.dragArea,'touchmove',this.onTouchMoveBind);
 
963
            }
 
964
            if(this.options.onTouchEnd){
 
965
              Event.stopObserving(this.dragArea,'touchend',this.onTouchEndBind);
 
966
            }
 
967
            
 
968
            if(this.options.onGestureStart){
 
969
              Event.stopObserving(this.dragArea,'gesturestart',this.onGestureStartBind);
 
970
            }
 
971
            if(this.options.onGestureMove){
 
972
              Event.stopObserving(this.dragArea,'gesturemove',this.onGestureMoveBind);
 
973
            }
 
974
            if(this.options.onGestureEnd){
 
975
              Event.stopObserving(this.dragArea,'gestureend',this.onGestureEndBind);
 
976
            }
 
977
            if(this.options.onOrientationChange){
 
978
              Event.stopObserving(this.dragArea,'orientationchange', this.onOrientationChange);
 
979
            }
 
980
 
917
981
                        Event.stopObserving( document, 'mouseup', this.endCropBind );
918
982
//                      Event.stopObserving( this.imgWrap, 'mouseup', this.endCropBind );
919
983
                        Event.stopObserving( this.dragArea, 'dblclick', this.dblClickBind );
1578
1642
                Event.stop( e );
1579
1643
        },
1580
1644
        
1581
 
        /**
 
1645
  onTouchStart: function(e){
 
1646
    this.Prevent(e);
 
1647
    var pos = this.getCurTouchPos(e);
 
1648
      this.options.onTouchStart(e,pos);
 
1649
  },
 
1650
  onTouchMove: function(e){
 
1651
    this.Prevent(e);
 
1652
    var xpos = this.getCurTouchPos(e);
 
1653
      this.options.onTouchMove(e,xpos);
 
1654
  },
 
1655
  onTouchEnd: function(e){
 
1656
    this.options.onTouchEnd(e);
 
1657
  },
 
1658
  onGestureStart: function(e){
 
1659
    this.options.onGestureStart(e);
 
1660
  },
 
1661
  onGestureMove: function(e){
 
1662
    this.Prevent(e); 
 
1663
    var scale = e.scale;
 
1664
    this.options.onGestureMove(e,scale);
 
1665
  },
 
1666
  onGestureEnd: function(e){
 
1667
    var scale = e.scale;
 
1668
    var angle = e.rotation;
 
1669
    this.options.onGestureEnd(e,scale,angle);
 
1670
  },
 
1671
  
 
1672
  onOrientationChange: function(e){
 
1673
    this.options.onOrientationChange(e);
 
1674
  },
 
1675
  
 
1676
  Prevent: function(e){
 
1677
    e.preventDefault();
 
1678
  },
 
1679
  
 
1680
  /** Gets touchposition
 
1681
   * returns an Object.
 
1682
   */
 
1683
  getCurTouchPos: function(e){
 
1684
    var curpos = new Object();
 
1685
    var el = this.imgWrap, wrapOffsets = Position.cumulativeOffset(el);
 
1686
 
 
1687
    curpos.x = e.targetTouches[0].clientX - wrapOffsets[0];
 
1688
    curpos.y = e.targetTouches[0].clientY - wrapOffsets[1];
 
1689
 
 
1690
    
 
1691
    return curpos;
 
1692
 
 
1693
    
 
1694
  },
 
1695
/**
1582
1696
         * Starts the drag
1583
1697
         * 
1584
1698
         * @access private
1854
1968
            var curpos = this.getMousePosition (ev);
1855
1969
            this.options.onDblClick(ev, curpos);
1856
1970
        },
1857
 
        
 
1971
    
1858
1972
        mouseScroll : function(ev) {
1859
1973
            if (this.options.onMouseScroll) {
1860
1974
                this.dragging = false;