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

@twreporter/scrollable-image

v1.3.2

Published

The Reporter scrollable image component

Downloads

502

Readme

scrollable-image

npm (latest) npm (rc)

What is this

A React component built by The Reporter Taiwan.

Published as an npm package.

It has been used in the news articles of The Reporter Taiwan

Examples:

We also provide a component generator as a web service, see the User Guide(zh-tw).

How to use this package

Install

yarn add @twreporter/scrollable-image

or you can use npm:

npm install --save @twreporter/scrollable-image

Usage

Scrollable Image Component

import scrollableImage under the component you want to have a horizontally scrollable image.

import scrollableImage from '@twreporter/scrollable-image'

export default class YourComponent extends React.Component {

  // Provide image links
  const testingImageSrcs = ['https://test-image-1.jpg', 'https://test-image-2.jpg']

  // Use it with other components
  const someWhereInYourComponent = (
    <div>
      <OtherComponent />
      <scrollableImage.Component imgSrc={testingImageSrcs} />
      <OtherComponent />
    </div>
  )

  // Or just use it standalone
  const standalone = (
    <scrollableImage.Component imgSrc={testingImageSrcs} />
  )

  render() {
    return (
      <div>{someWhereInPage}</div>
    )
  }
}
Props

| props | type | default | description | | -------- | ------- | ------- | ------------------------------------------------------------------------------------------------------------------------------- | | data | Array | | Array of string which is image link and will be the src of <img>. | | lazyload | Boolean | false | Whether to enable lazyload to load scrollableImage component only when its top edge is within 300 viewport height to viewport |

Build Embedded Code

In rare cases, you want to build embedded code and make it embed in <body> element of a HTML document.

import scrollableImage from '@twreporter/scrollable-image'
import scrollableImageAssets from '@twreporter/scrollable-image/dist/webpack-assets.json'

// Provide image links
const testingImageSrcs = [
  'https://test-image-1.jpg',
  'https://test-image-2.jpg',
]

const embeddedCode = scrollableImage.buildEmbeddedCode(
  {
    data: testingImageSrcs,
  },
  scrollableImageAssets
)

How to develop this package

  1. We use webpack-dev-server to render a mock data for development.

    # Start the webpack-dev-server
    make dev-server
  2. Or use babel --watch to complie the source file if there's any change happened

    make dev
  3. If you need to update the embedded code, there is an embedded code testing server serves a html document with injected embedded code

# Build testing embedded code and start express server to test it
make test-embedded-code

How to publish this package

# Babel transpile es6 and above to es5 at lib/
# Build webpack bundles, chunks and webpack-assets.json to dist/
# Files in lib/ and dist/ folders will be published to npm

make build
yarn publish
# OR
npm publish