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

d-image-edit

v0.4.3

Published

A Derby JS component for editing images.

Downloads

6

Readme

Derby Image Edit

A Derby JS component for editing images. It uses Derby Panzoom to edit images.

Features

  • Resize and crop images by panning and zooming.
  • Display your image in a container smaller than the final image size.
  • All of the features in jQuery Panzoom (transitions, etc.)

Installation

$ npm install d-image-edit --save

Dependencies

This component extends Derby Panzoom which, requires jQuery Panzoom in order to work. You must include the script on the page.

Usage

Create a view:

<index: element="image-edit">
  <div as="container">
    <img alt="" as="image" src="{{@src}}">
  </div>
  <!-- must use hidden/visible classes rather than {{if}} blocks -->
  <div class="{{if !canScale}}hidden{{/if}}">
    <button on-click="zoom(true)" type="button">Zoom out</button>
    <input type="range" as="range">
    <button on-click="zoom()" type="button">Zoom in</button>
  </div>

Associate the view with the component:

app.use('image-edit', require('d-image-edit'));

Use the view:

<Scripts:>
  <script src="jquery.panzoom.js">

<Body:>
  <edit contain="invert" on-draw="save()" src="..."></edit>

Elements

image (Required) - The <img> element that should contain the image source.

input - The <input type="file"> element that can select a new image.

range - The <input type="range"> element that can zoom in and out.

Data

The following path data is available to the view implementing the component:

canScale - True if the computed max scale is greater than the min scale. Use this to conditionally display zoom in and zoom out controls.

from.image - The image used to draw the final image.

loading - True while the image is loading.

to.image - The final image.

Options

debounce - The wait time before a re-draw occurs after a change.

filetype - The file type to draw the image as. Defaults to png.

size - The width and height of the final image.

width - The width of the final image. Overrides size.

height - The height of the final image. Overrides size.

Functions

clear() - Clear all image data.

Events

clear() - Event emitted after the image is cleared.

draw(image) - Event emitted after a new image is drawn based on changes by panning or zooming.

load(image) - Event emitted after the image is loaded.

Other

There are more options, events and functions. See Derby Panzoom.

Notes

Be careful about wrapping special elements such as input and range in {{if}} blocks. If the {{if}} block evaluates to false then the server will not render the initial element and it won't be found by the component. Use hidden or visible classes to toggle visibility instead.