How to use the @egjs/axes function in @egjs/axes

To help you get started, we’ve selected a few @egjs/axes 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 naver / egjs-view360 / src / SpinViewer / SpinViewer.js View on Github external
*		// Error handling
				 *		console.log(e.imageUrl);
				 *	}
				 * });
				 */
				this.trigger("imageError", {
					imageUrl: evt.imageUrl
				});
			}
		});

		// Init Axes
		this._panInput = new PanInput(this._el, {
			scale: [this._panScale, this._panScale]
		});
		this._axes = new Axes({
			angle: {
				range: [0, 359],
				circular: true
			}
		}).on({
			"change": evt => {
				const curr = Math.floor(evt.pos.angle / (360 / this._frameCount));
				const frameIndex = this._frameCount - curr - 1;

				this._sprites.setFrameIndex(frameIndex);

				/**
				 * An event that occurs when the image index is changed by the user's left / right panning
				 * @ko 사용자의 좌우 Panning 에 의해 이미지 인덱스가 변경되었을때 발생하는 이벤트
				 * @name eg.view360.SpinViewer#change
				 * @event
github naver / egjs-flicking / src / Flicking.js View on Github external
width: utils.getUnitValue(sizeValue[0]),
				height: utils.getUnitValue(sizeValue[1]),
				boxSizing: "border-box",
				top: 0,
				left: 0
			});
		});

		if (this._addClonePanels()) {
			panelCount = panel.count = (
				panel.$list = utils.toArray(this.$container.children)
			).length;
		}

		// create Axes instance
		this._axesInst = new Axes({
			flick: {
				range: [0, panel.size * (panelCount - 1)],
				bounce
			}
		}, {
			easing: options.panelEffect,
			deceleration: options.deceleration,
			interruptable: false
		});

		this._setDefaultPanel(options.defaultIndex);
	}
github naver / egjs-flicking / src / components / Viewport.ts View on Github external
private setAxesInstance(): void {
    const state = this.state;
    const options = this.options;

    const scrollArea = state.scrollArea;
    const horizontal = options.horizontal;

    this.axes = new Axes({
      flick: {
        range: [scrollArea.prev, scrollArea.next],
        circular: options.circular,
        bounce: [0, 0], // will be updated in resize()
      },
    }, {
      easing: options.panelEffect,
      deceleration: options.deceleration,
      interruptable: true,
    });

    this.panInput = new PanInput(this.viewportElement, {
      inputType: options.inputType,
      thresholdAngle: options.thresholdAngle,
      scale: options.horizontal ? [-1, 0] : [0, -1],
    });
github naver / egjs-flicking / release / latest / dist / flicking.esm.js View on Github external
__proto.setAxesInstance = function () {
    var state = this.state;
    var options = this.options;
    var scrollArea = state.scrollArea;
    var horizontal = options.horizontal;
    this.axes = new Axes({
      flick: {
        range: [scrollArea.prev, scrollArea.next],
        circular: options.circular,
        bounce: [0, 0]
      }
    }, {
      easing: options.panelEffect,
      deceleration: options.deceleration,
      interruptable: true
    });
    this.panInput = new PanInput(this.viewportElement, {
      inputType: options.inputType,
      thresholdAngle: options.thresholdAngle,
      scale: options.horizontal ? [-1, 0] : [0, -1]
    });
    this.axes.connect(horizontal ? ["flick", ""] : ["", "flick"], this.panInput);
github naver / egjs-view360 / test / unit / YawPitchControl / MoveKeyInput.spec.js View on Github external
beforeEach(() => {
				moveKeyInput = new MoveKeyInput(document.body, {scale:[1, 1]});
				axes = new Axes({
					yaw: {range: [0, 20]},
					pitch: {range: [0, 20]}
				})
				.on({
					change: e => {
						changed = true;
						deltaYaw = e.delta.yaw;
						deltaPitch = e.delta.pitch;
					}
				}).connect(["yaw", "pitch"], moveKeyInput);
			});
github naver / egjs-view360 / test / unit / YawPitchControl / TiltMotionInput.spec.js View on Github external
beforeEach(() => {
				tiltMotionInput = new TiltMotionInput(document.body);
				axes = new Axes({
					yaw: {range: [-180, 180]},
					pitch: {range: [-110, 110]}
				}, {}, {
					yaw: 0,
					pitch: 0
				})
				.connect(["yaw", "pitch"], tiltMotionInput);
			});
github naver / egjs-axes / packages / react / src / Axes.js View on Github external
events[name.replace("on", "").toLowerCase()] = props[name];
            }
        }

        const propsAxis = this.props.axis;

        for (const name in propsAxis) {
            if (Array.isArray(propsAxis[name])) {
                axis[name] = {
                    range: propsAxis[name],
                };
            } else {
                axis[name] = propsAxis[name];
            }
        }
        this.axes = new NativeAxes(axis, options);
        for (const name in events) {
            this.axes.on(name, events[name]);
        }
        this.axes.on("change", this.onChange.bind(this));
        this.axes.on("hold", this.onHold.bind(this));
        this.axes.on("release", this.onRelease.bind(this));
        const pos = this.axes.get();

        this.state = {
            pos,
            delta: toZeroAxis(this.axes.axis),
            holding: false,
            isTrusted: false,
        };
    }
    onChange(e) {
github naver / egjs-view360 / src / YawPitchControl / YawPitchControl.js View on Github external
_initAxes(opt) {
		const yRange = this._updateYawRange(opt.yawRange, opt.fov, opt.aspectRatio);
		const pRange = this._updatePitchRange(opt.pitchRange, opt.fov, opt.showPolePoint);
		const useRotation = opt.gyroMode === GYRO_MODE.VR;

		this.axesPanInput = new RotationPanInput(this._element, {useRotation});
		this.axesWheelInput = new WheelInput(this._element, {scale: -4});
		this.axesTiltMotionInput = null;
		this.axesPinchInput = SUPPORT_TOUCH ? new PinchInput(this._element, {scale: -1}) : null;
		this.axesMoveKeyInput = new MoveKeyInput(this._element, {scale: [-6, 6]});

		this.axes = new Axes({
			yaw: {
				range: yRange,
				circular: YawPitchControl.isCircular(yRange),
				bounce: [0, 0]
			},
			pitch: {
				range: pRange,
				circular: YawPitchControl.isCircular(pRange),
				bounce: [0, 0]
			},
			fov: {
				range: opt.fovRange,
				circular: [false, false],
				bounce: [0, 0]
			},
		}, {
github daybrush / scenejs-editor / packages / react-scenejs-timeline / src / react-scenejs-timeline / Timeline.tsx View on Github external
constructor(props: any) {
        super(props);

        this.state = { ...this.state, ...this.initScene(this.props.scene, false) };

        this.keycon = new KeyController()
            .keydown("alt", () => {
                this.setState({ alt: true });
            })
            .keyup("alt", () => {
                this.setState({ alt: false });
            });
        this.axes = new Axes(
            {
                zoom: {
                    range: [1, Infinity],
                },
            },
            {},
            { zoom: 1 },
        );
    }
    public render() {

@egjs/axes

A module used to change the information of user action entered by various input devices such as touch screen or mouse into the logical virtual coordinates. You can easily create a UI that responds to user actions.

MIT
Latest version published 3 months ago

Package Health Score

75 / 100
Full package analysis

Similar packages