src/components/bottomSheet/bottom-sheet.js
function registerGestures(element, parent) {
      var deregister = $mdGesture.register(parent, 'drag', { horizontal: false });
      parent.on('$md.dragstart', onDragStart)
        .on('$md.drag', onDrag)
        .on('$md.dragend', onDragEnd);

      return function cleanupGestures() {
        deregister();
        parent.off('$md.dragstart', onDragStart);
        parent.off('$md.drag', onDrag);
        parent.off('$md.dragend', onDragEnd);
      };

      function onDragStart() {
        // Disable transitions on transform so that it feels fast
        element.css($mdConstant.CSS.TRANSITION_DURATION, '0ms');
      }

      function onDrag(ev) {
        var transform = ev.pointer.distanceY;
        if (transform < 5) {
          // Slow down drag when trying to drag up, and stop after PADDING
          transform = Math.max(-PADDING, transform / 2);
        }
        element.css($mdConstant.CSS.TRANSFORM, 'translate3d(0,' + (PADDING + transform) + 'px,0)');
      }

      function onDragEnd(ev) {
        if (ev.pointer.distanceY > 0 &&
            (ev.pointer.distanceY > 20 || Math.abs(ev.pointer.velocityY) > CLOSING_VELOCITY)) {
          var distanceRemaining = element.prop('offsetHeight') - ev.pointer.distanceY;
          var transitionDuration = Math.min(distanceRemaining / ev.pointer.velocityY * 0.75, 500);
          element.css($mdConstant.CSS.TRANSITION_DURATION, transitionDuration + 'ms');
          $mdUtil.nextTick($mdBottomSheet.cancel,true);
        } else {
          element.css($mdConstant.CSS.TRANSITION_DURATION, '');
          element.css($mdConstant.CSS.TRANSFORM, '');
        }
      }
    }
function registerGestures(element, parent) {
      var deregister = $mdGesture.register(parent, 'drag', { horizontal: false });
      parent.on('$md.dragstart', onDragStart)
        .on('$md.drag', onDrag)
        .on('$md.dragend', onDragEnd);

      return function cleanupGestures() {
        deregister();
        parent.off('$md.dragstart', onDragStart);
        parent.off('$md.drag', onDrag);
        parent.off('$md.dragend', onDragEnd);
      };

      function onDragStart() {
        // Disable transitions on transform so that it feels fast
        element.css($mdConstant.CSS.TRANSITION_DURATION, '0ms');
      }

      function onDrag(ev) {
        var transform = ev.pointer.distanceY;
        if (transform < 5) {
          // Slow down drag when trying to drag up, and stop after PADDING
          transform = Math.max(-PADDING, transform / 2);
        }
        element.css($mdConstant.CSS.TRANSFORM, 'translate3d(0,' + (PADDING + transform) + 'px,0)');
      }

      function onDragEnd(ev) {
        if (ev.pointer.distanceY > 0 &&
            (ev.pointer.distanceY > 20 || Math.abs(ev.pointer.velocityY) > CLOSING_VELOCITY)) {
          var distanceRemaining = element.prop('offsetHeight') - ev.pointer.distanceY;
          var transitionDuration = Math.min(distanceRemaining / ev.pointer.velocityY * 0.75, 500);
          element.css($mdConstant.CSS.TRANSITION_DURATION, transitionDuration + 'ms');
          $mdUtil.nextTick($mdBottomSheet.cancel,true);
        } else {
          element.css($mdConstant.CSS.TRANSITION_DURATION, '');
          element.css($mdConstant.CSS.TRANSFORM, '');
        }
      }
    }
function registerGestures ( element , parent ) { var deregister = $mdGesture . register ( parent , 'drag' , { horizontal : false } ) ; parent . on ( '$md.dragstart' , onDragStart ) . on ( '$md.drag' , onDrag ) . on ( '$md.dragend' , onDragEnd ) ; return function cleanupGestures ( ) { deregister ( ) ; parent . off ( '$md.dragstart' , onDragStart ) ; parent . off ( '$md.drag' , onDrag ) ; parent . off ( '$md.dragend' , onDragEnd ) ; } ; function onDragStart ( ) { // Disable transitions on transform so that it feels fast element . css ( $mdConstant . CSS . TRANSITION_DURATION , '0ms' ) ; } function onDrag ( ev ) { var transform = ev . pointer . distanceY ; if ( transform < 5 ) { // Slow down drag when trying to drag up, and stop after PADDING transform = Math . max ( - PADDING , transform / 2 ) ; } element . css ( $mdConstant . CSS . TRANSFORM , 'translate3d(0,' + ( PADDING + transform ) + 'px,0)' ) ; } function onDragEnd ( ev ) { if ( ev . pointer . distanceY > 0 && ( ev . pointer . distanceY > 20 || Math . abs ( ev . pointer . velocityY ) > CLOSING_VELOCITY ) ) { var distanceRemaining = element . prop ( 'offsetHeight' ) - ev . pointer . distanceY ; var transitionDuration = Math . min ( distanceRemaining / ev . pointer . velocityY * 0.75 , 500 ) ; element . css ( $mdConstant . CSS . TRANSITION_DURATION , transitionDuration + 'ms' ) ; $mdUtil . nextTick ( $mdBottomSheet . cancel , true ) ; } else { element . css ( $mdConstant . CSS . TRANSITION_DURATION , '' ) ; element . css ( $mdConstant . CSS . TRANSFORM , '' ) ; } } }
Adds the drag gestures to the bottom sheet.
Adds the drag gestures to the bottom sheet .