How to use the popmotion.pointer function in popmotion

To help you get started, we’ve selected a few popmotion 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 brunnolou / gleis / src / index.js View on Github external
startDragging(e) {
    e.preventDefault();

    this.startAction(pointer(e));
    const pointerX = this.currentAction.x.get();
    this.currentAction.setProps({
      onUpdate: pipe(
        // Select the `x` pointer value
        ({ x }) => x,
        // Subtract the pointer origin to get the pointer offset
        // Apply the offset to the slider's origin offset
        add(this.getOffset()),
        subtract(pointerX),
        // Apply a spring if the slider is out of bounds.
        conditional(
          v => v > this.bounds[0],
          nonlinearSpring(this.snapSettings.boundsElasticity, this.bounds[0]),
        ),
        conditional(
          v => v < this.bounds[1],
github Popmotion / popmotion / packages / site / templates / Popmotion / LiveExamples / Pointer.js View on Github external
listen(ref, 'mousedown touchstart').start(e => {
      e.preventDefault();
      pointer(ballXY.get()).start(ballXY);
    });
github Popmotion / popmotion / packages / site / templates / Popmotion / LiveExamples / Decay.js View on Github external
listen(ref, 'mousedown touchstart').start(() =>
      pointer({ x: this.sliderX.get() })
        .pipe(({ x }) => x, clampMovement)
        .start(this.sliderX)
    );
github clari / react-ios-switch / src / Switch.jsx View on Github external
handleMouseDown(e) {
    if (this.isDisabled()) {
      return;
    }
  
    this.pointerTracker = pointer(e).start();
    
    this.offsetTracker = trackOffset(this.pointerTracker.x, {
      from: this.getOffset(),
      onUpdate: transform.pipe(
        transform.clamp(0, this.getOffsetWidth()),
        offset => this.setState({ offset })
      ),
    }).start();
    
    this.setState({
      isDragging: true,
      offset: this.getOffset(),
    });
  }
github Popmotion / popmotion / packages / site / templates / Popmotion / LiveExamples / Spring.js View on Github external
listen(ref, 'mousedown touchstart').start(e => {
      e.preventDefault();
      pointer(this.ballXY.get()).start(this.ballXY);
    });
github Popmotion / popmotion / packages / popmotion-pose / src / inc / default-transitions.ts View on Github external
const singleAxisPointer = (axis: string) => (from: number | string) =>
  pointer({
    [axis]: typeof from === 'string' ? parseFloat(from) : from
  }).pipe((v: any) => v[axis]);
const pointerX = singleAxisPointer('x');
github HuijiFE / void-ui / src / controls / layout / carousel / VdCarousel.tsx View on Github external
const update: (x: number) => void =
      left && right
        ? left === right
          ? (x: number) => {
              this.selectedPanel.styler.set('x', `${x}%`);
              left.styler.set('x', `${x < 0 ? x + 100 : x - 100}%`);
            }
          : (x: number) => {
              this.selectedPanel.styler.set('x', `${x}%`);
              left.styler.set('x', `${x - 100}%`);
              right.styler.set('x', `${x + 100}%`);
            }
        : (x: number) => this.selectedPanel.styler.set('x', `${x}%`);

    const wrapperWidth: number = this.wrapperStyler.get('width');
    this.subscription = popmotion
      .pointer({ x: 0 })
      .pipe(({ x }: { x: number }) => (this.delta = clamp100((x / wrapperWidth) * 100)))
      .start(update);
  }
github digirati-labs / hyperion / packages / atlas / src / controller / popmotion-controller.ts View on Github external
listen(canvas, 'mousedown touchstart').start((e: { touches: [] }) => {
    const { x, y } = viewer.get() as Position;
    pointer({
      x: (-x * runtime.scaleFactor) / devicePixelRatio,
      y: (-y * runtime.scaleFactor) / devicePixelRatio,
    })
      .pipe((v: Position): Position => ({ x: v.x * devicePixelRatio, y: v.y * devicePixelRatio }))
      .pipe((v: Position): Position => ({ x: -v.x / runtime.scaleFactor, y: -v.y / runtime.scaleFactor }))
      .start(viewer);
  });
github Popmotion / popmotion / packages / popmotion-pose / dist / popmotion-pose.es.js View on Github external
return function (from) {
        return pointer((_a = {}, _a[axis] = from, _a)).pipe(function (v) {
            return v[axis];
        });
        var _a;
    };
};