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

jquery-select-areas

v0.1.0

Published

jQuery-select-areas is a jQuery plugin that let you select multiple areas of an image, move them and resize them.

Downloads

1,907

Readme

jQuery-select-areas

jQuery-select-areas is a jQuery plugin that let you select multiple areas of an image, move them and resize them.

It is used by:

jQuery-select-areas Preview

Project continuation

We (360Learning) no longer have the time to maintain this project, so the issue tracker has been closed. If someone wants to get admin access to this repository to fix the few bugs that are reported, we would gladly agree. Else, there already are some forks of this project, so don't hesitate to use them if they have fixed a bug that is bother you. Best regards

Quick Start

Use like so:

$("#mypic").selectAreas({
  minSize: [30, 30],    // Minimum size of a selection
  maxSize: [400, 300],  // Maximum size of a selection
  onChanged: $.noop,    // fired when a selection is released
  onChanging: $.noop    // fired during the modification of a selection
});

Want an example to learn from?

Check out example/example.html

Browser Compatibiilty:

This plugin is fully compatible with every modern browser and IE >= 9.

One of the features : scaling image, in order to display it smaller or bigger than it actually is, is not compatible with IE8. If you need to use this feature and to maintain a compatibility with IE8, you can add the alternate stylesheet resources/jquery.selectareas.ie8.css. This will make it work but uglify the whole plugin. This stylesheet can be added for IE8 only with conditional comments (see example/example.html).

API Doc

Area

An area is described (when retrieved or set) by a json object:

{
    id, // ID identifying the area in the plugin
    x,  // X coordinate (Position)
    y,  // Y coordinate (Position)
    z,  // Z-index (0 when inactive or 100 when focused)
    width,  // Width of the area (Size)
    height  // Height of the area (Size)
}

Options

Here is a list of available options for selectAreas, with their default value:

  • allowEdit (true) : When set to false, unset allowMove, allowResize, allowSelect and allowDelete
  • allowMove (true) : When set to false, Areas can not be moved with a drag & drop.
  • allowResize (true) : When set to false, Areas can not be resized.
  • allowSelect (true) : When set to false, Areas can not be created.
  • allowDelete (true) : When set to false, Areas can not be deleted.
  • allowNudge (true) : When set to false, Areas can not be moved with arrow keys.
  • aspectRatio (0) : When not 0, force a ratio between height and width for the selections.
  • minSize ([0, 0]) : When not 0, set the minimum size for a selection [width, height]
  • maxSize ([0, 0]) : When not 0, set the maximum size for a selection [width, height]
  • maxAreas (0) : When not 0, set the maximum number of area that can be drawn.
  • outlineOpacity (0.5) : opacity of the moving dotted outline around a selection.
  • overlayOpacity (0.5) : opacity of the overlay layer over the image
  • areas ([]) : list of areas to add to the image from the beginning (id will be ignored)
  • onChanging (null) : triggered when the event "changing" is fired
  • onChanged (null) : triggered when the event "changed" is fired
  • onLoaded (null) : triggered when the event "loaded" is fired
  • width (0) : When not 0, scale the image to this width (px). The coordinates of the areas on the full image can be retrieved with method relativeAreas()

Events

Three events are fired by the plugin:

  • loaded : fired when plugin is loaded
  • changing : fired during the modification of a selection. arguments : (event, id, areas)
  • changed : fired when a selection is released. arguments : (event, id, areas)

Methods

Once you added a selectAreas plugin on an image, several method are exposed to help you manipulate and retrieve these areas:

  • areas () : returns an array of areas
  • relativeAreas () : returns an array of areas, with their size and coordinates on the original image (see option width). Equal to areas() when the image is displayed in full size.
  • add (options) : add an area
  • remove (id) : remove an area with its id
  • reset () : remove all areas
  • destroy () : remove the selectAreas plugin
  • blurAll () : blur (unfocus) all the areas
  • contains (point) : return true or false whether or not a point ({x: X, y: Y}) is included in at least one area