npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-tridi-alt

v2.1.6

Published

360-degree product viewer

Downloads

5

Readme

react-tridi

React Tridi is a light-weight react component for 360-degree product viewer

NPM JavaScript Style Guide

Inspired by the Tridi javascript library for 360-degree 3D product visualizations based on series of images. Special thanks to Łukasz Wójcik

Install


npm install --save react-tridi

Usage

Simple

Here is the simplest case of using React Tridi. You just need to specify an images' location, its format, and total of the images.

Sample code:

import React from 'react';
import Tridi from 'react-tridi';
import 'react-tridi/dist/index.css';

const Example = () => (
    <div style={{ width: '500px' }}>
        <Tridi location="./images" format="jpg" count="36" />
    </div>
);

With Pins

In this mode, you can load some pin points on top of the product images. There is an onClick event on each pin with the pin's information returned, so you can show the product information on that event if needed.

The pins data structure looks like this:

const pins = [
  { "id": "kcyvybbrjkr8lz7w1j", "frameId": 0, "x": "0.664000", "y": "0.570922", "recordingSessionId": "klbp4jr3r7vyy5nnmkg" },
  { "id": "kcyvybrdbqwmi3z1ig", "frameId": 1, "x": "0.340000", "y": "0.500000", "recordingSessionId": "klbp4jr3r7vyy5nnmkg" },
]

You can record pins' coordinates via the recoding mode of the React Tridi with the following steps:

  1. Enable the prop showControlBar to show functionality buttons.
  2. Click the target icon to start recoding the coordinates.
  3. Click on the image view area to create a pin. Double click the pin to remove it. You can click the Next & Prev button to move to other frames, and create other pins on them.
  4. On each start and stop recording event, an array of pins' information like above will be returned.

You can also render a custom pin point if needed by using the renderPin prop.

Sample code:

import React from 'react';
import Tridi from 'react-tridi';
import 'react-tridi/dist/index.css';

const Example = () => (
    <div style={{ width: '500px' }}>
      <Tridi
        location="./images"
        format="jpg"
        count="36"
        autoplaySpeed={70}
        onRecordStart={recordStartHandler}
        onRecordStop={recordStopHandler}
        onPinClick={pinClickHandler}
        renderPin={(pin) => (<span>A</span>)}
        inverse
        showControlBar
      />
    </div>
);

With Customized Control Buttons

If you do not like the default control buttons, React Tridi gives you a ref accessing to all the button actions.

Sample code:

import React, { useState, useRef } from 'react';
import Tridi from 'react-tridi';
import 'react-tridi/dist/index.css';

const Example = () => {
    const [isAutoPlayRunning, setIsAutoPlayRunning] = useState(false);
  const tridiRef = useRef(null);
  
  return (
    <div style={{ width: '500px' }}>
      <Tridi
        ref={tridiRef}
        location="./images"
        format="jpg"
        count="36"
      />
      <button onClick={() => tridiRef.current.prev()}>Prev</button>
      <button onClick={() => tridiRef.current.next()}>Next</button>
      <button onClick={() => tridiRef.current.toggleAutoplay(!isAutoPlayRunning)}>
        {isAutoPlayRunning ? 'Pause' : 'Autoplay'}
      </button>
    </div>
  );
};

Props

| Prop Name | Prop Type | Default Value | Required? | Description | | ---------------- |:-------------------:|:--------------:|:---------:| ----------- | | className | string | undefined | no | Add class name for the component | style | object | undefined | no | Add style for the component | images | arrays | "numbered" | no | Source of images to be used by Tridi | pins | arrays | undefined | no | Pin coordinates to show on the product | format | string | undefined | yes* | Image extension (e.g. "jpg"). Required if images = "numbered" | location | string | undefined | yes* | Path to images folder. Required if images = "numbered" | count | number | undefined | yes* | Number of images in the series. Required if images = "numbered" | draggable | boolean | true | no | Enable/disable mouse drag event | hintOnStartup | boolean | false | no | Enable/disable hint on start up | hintText | string | undefined | no | Enable/disable hint text | autoplay | boolean | false | no | Enable/disable autoplay | autoplaySpeed | number | 50 | no | Adjust autoplay speed | stopAutoplayOnClick | boolean | false | no | Stop autoplay if user clicks on container | stopAutoplayOnMouseEnter | boolean | false | no | Stop autoplay if user hovers over container | resumeAutoplayOnMouseLeave | boolean | false | no | Resume autoplay if user moves mouse cursor away from container | touch | boolean | true | no | Enable/disable touch support | mousewheel | boolean | false | no | Enable/disable mousewheel support | inverse | boolean | false | no | Swap image rotation direction. Affects mouse drag, mousewheel and touch | dragInterval | number | 1 | no | Adjust rotation speed for mouse drag events | touchDragInterval | number | 2 | no | Adjust rotation speed for touch events | mouseleaveDetect | boolean | false | no | If true, active drag event will stop whenever mouse cursor leaves Tridi container | showControlBar | boolean | false | no | show a control bar with record, play, pause, next, prev functions | showStatusBar | boolean | false | no | show a status bar on recording | hideRecord | boolean | false | no | hide record button in the control bar | zoom | number | 1 | no | default zoom value | minZoom | number | 1 | no | minimum zoom value | maxZoom | number | 3 | no | maximum zoom value | renderPin | func | undefined | no | render a customized pin point | setPins | func | undefined | no | function to set pin's state | renderHint | func | undefined | no | render a customized hint message

Prop Events

| Prop Name | Params Type | Description | | --------- | ------ | ----------- | | onHintHide | null | Hint is hidden | onAutoplayStart | null | Autoplay is started | onAutoplayStop | null | Autoplay is stopped | onNextMove | null | Next image is loaded (obeying inverse option) | onPrevMove | null | Previous image is loaded (obeying inverse option) | onNextFrame | null | Next image is loaded following the order in the image source (indifferent to inverse option) | onPrevFrame | null | Previous image is loaded according to the order in the image source (indifferent to inverse option) | onDragStart | null | Image rotation sequence (dragging) starts | onDragEnd | null | Image rotation sequence (dragging) ends | onFrameChange | number | Next image is loaded, sending out the current image index | onRecordStart | null | get current sessionId on start recording | onRecordStop | null | get current sessionId on stop recording | onPinClick | null | get a pin info on click in normal mode | onZoom | null | get the current zoom scale value | onLoadChange | load_success, percentage | load_success: get whether all images have been loaded, percentage: current load percentage

Ref Functions

| Function Name | Params Type | Description | | ------------- | ----------- | ----------- | | prev() | null | trigger prev move | next() | null | trigger next move | toggleAutoPlay(true/false) | boolean | toogle autoplay | toggleRecording(true/false) | boolean | toggle recording pins' coordinates | toggleMoving(true/false) | boolean | toogle moving photo while zooming

License

MIT © nevestuan