How to use the hammerjs.DIRECTION_RIGHT function in hammerjs

To help you get started, we’ve selected a few hammerjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ubyssey / dispatch / dispatch / themes / ubyssey / static / js / src / components / Gallery.jsx View on Github external
// slow down at the first and last pane
                if((this.current_pane == 0  && ev.direction == Hammer.DIRECTION_RIGHT) ||
                   (this.current_pane == this.pane_count-1 && ev.direction == Hammer.DIRECTION_LEFT)) {
                  drag_offset *= .4;
                }

                this.setContainerOffset(drag_offset + pane_offset);
                break;

            case 'panend':
            case 'pancancel':
                // Left & Right
                // more then 1/3 moved, navigate
                if(Math.abs(ev.deltaX) > this.pane_width/3) {
                  if(ev.direction == Hammer.DIRECTION_RIGHT) {
                    this.prevSlide();
                  } else {
                    this.nextSlide();
                  }
                }
                else {
                  this.showPane(this.current_pane, true);
                }

                break;

            case 'swipeleft':
                this.nextSlide();
                break;

            case 'swiperight':
github Workiva / wf-uicomponents / test / awesome_map / CustomSwipeGestureSpec.js View on Github external
it('should set direction to "right" when swiping right', function() {
                simulateSwipeGestureMoves(hammerInstance, { deltaX: 0 }, { deltaX: 2 });
                CustomSwipeGesture.handler(endEvent, hammerInstance);
                expect(endEvent.direction).toBe(Hammer.DIRECTION_RIGHT);
            });
            it('should set direction to "up" when swiping up', function() {
github kappys1 / angular2-carousel / dist / src / carousel.component.js View on Github external
this.carouselElm.nativeElement.addEventListener('transitionstart', function (e) {
            var elm = { carousel: vm.carousel, event: e };
            if (e.propertyName === "transform") {
                _this.onTransitionStart.emit(elm);
                if (e.direction === Hammer.DIRECTION_LEFT) {
                    vm.onSlideNextTransitionStart.emit(elm);
                }
                else if (e.direction === Hammer.DIRECTION_RIGHT) {
                    vm.onSlidePrevTransitionStart.emit(elm);
                }
            }
        });
        window.addEventListener("resize", function () {
github kappys1 / angular2-carousel / src / carousel.component.ts View on Github external
this.carouselElm.nativeElement.addEventListener('transitionstart', (e : any) =>{
      let elm = {carousel:vm.carousel,event:e};
      if(e.propertyName === "transform"){
          this.onTransitionStart.emit(elm);
          if(e.direction === Hammer.DIRECTION_LEFT){
              vm.onSlideNextTransitionStart.emit(elm);
          }
          else if(e.direction === Hammer.DIRECTION_RIGHT){
              vm.onSlidePrevTransitionStart.emit(elm);
          }
      }
    });
    window.addEventListener("resize", function(){
github Workiva / wf-uicomponents / src / awesome_map / CustomSwipeGesture.js View on Github external
function getDirection() {
        var start = moves[0];
        var end = moves[moves.length - 1];
        var deltaX = Math.abs(end.deltaX - start.deltaX);
        var deltaY = Math.abs(end.deltaY - start.deltaY);
        if (deltaX >= deltaY) {
            return start.deltaX > end.deltaX ? Hammer.DIRECTION_LEFT : Hammer.DIRECTION_RIGHT;
        }
        return start.deltaY > end.deltaY ? Hammer.DIRECTION_UP : Hammer.DIRECTION_DOWN;
    }
github cozy / cozy-ui / react / Viewer / ViewerControls.jsx View on Github external
onSwipe = e => {
    if (e.direction === Hammer.DIRECTION_LEFT) this.props.onNext()
    else if (e.direction === Hammer.DIRECTION_RIGHT) this.props.onPrevious()
  }
github alexhisen / mobx-schema-form / src / DateField.jsx View on Github external
onSwipe = (e) => {
    switch (e.direction) {
      case Hammer.DIRECTION_LEFT: {
        const button = document.querySelector('[data-react-toolbox=calendar] button#right');
        if (button) {
          button.click();
        }
        break;
      }
      case Hammer.DIRECTION_RIGHT: {
        const button = document.querySelector('[data-react-toolbox=calendar] button#left');
        if (button) {
          button.click();
        }
        break;
      }
    }
  };
github iawia002 / Diana / src / js / containers / article / index.js View on Github external
hljs.highlightBlock(block);
  });
  sr.reveal('.article', {viewFactor: 0.000001});
  $('html').removeClass('sr');

  const iv = new ImageGallery('.article');

  const stage = document.getElementById('content-model');
  const mc = new Hammer.Manager(stage);
  const SwipeLeft = new Hammer.Swipe({
    event: 'swipeleft',
    direction: Hammer.DIRECTION_LEFT,
  });
  const SwipeRight = new Hammer.Swipe({
    event: 'swiperight',
    direction: Hammer.DIRECTION_RIGHT,
  });
  const Tap = new Hammer.Tap();
  mc.add(SwipeLeft);
  mc.add(SwipeRight);
  mc.add(Tap);

  $('.article img').click((e) => {
    const index = iv.images.indexOf(e.target.src);
    iv.changeImage(index);
    $('.model').addClass('show animated fadeIn');
    setTimeout(() => {
      $('.model').removeClass('animated fadeIn');
    }, 300);
    $('body').addClass('model-open');
  });
github software-mansion / react-native-gesture-handler / web / PanGestureHandler.js View on Github external
activeOffsetXEnd,
      activeOffsetYStart,
      activeOffsetYEnd,
      minDist,
    } = config;
    let directions = [];
    let horizontalDirections = [];

    if (!isnan(minDist)) {
      return Hammer.DIRECTION_ALL;
    }

    if (!isnan(activeOffsetXStart))
      horizontalDirections.push(Hammer.DIRECTION_LEFT);
    if (!isnan(activeOffsetXEnd))
      horizontalDirections.push(Hammer.DIRECTION_RIGHT);
    if (horizontalDirections.length === 2)
      horizontalDirections = [Hammer.DIRECTION_HORIZONTAL];

    directions = directions.concat(horizontalDirections);
    let verticalDirections = [];

    if (!isnan(activeOffsetYStart))
      verticalDirections.push(Hammer.DIRECTION_UP);
    if (!isnan(activeOffsetYEnd))
      verticalDirections.push(Hammer.DIRECTION_DOWN);

    if (verticalDirections.length === 2)
      verticalDirections = [Hammer.DIRECTION_VERTICAL];

    directions = directions.concat(verticalDirections);
github arnoldczhang / fe-guide / src / vue / vue-mark-display / App.vue View on Github external
mc.on("swipe", event => {
      if (event.pointerType === "mouse") {
        return;
      }
      switch (event.direction) {
        case Hammer.DIRECTION_LEFT:
          display.goNext();
          return;
        case Hammer.DIRECTION_RIGHT:
          display.goPrev();
          return;
      }
    });
  },