Giter Club home page Giter Club logo

jqcrop's Introduction

jQCrop (v 1.0.3)

Easy to use jQuery plugin for zoom & pan image cropping. This plugin is a rewrite of https://github.com/adriengibrat/jQuery-crop which itself is a rewrite of https://github.com/blackbiron/jWindowCrop :)

The main addition to this plugin is the ability to set the options after initialization and have the plugin auto-recalculate offsets and crop sizes, along with the auto-repositioning of the image (if required). Besides, jQcrop has experimental touch support in the touch branch, based on the excellent hammer.js.

It's built in the style of sco.js library so if you're familiar with that, you should feel at home with this one too.

Usage

	$('img.crop').jQcrop({
		 width: 600
		,height: 300
	}).on('crop.jQcrop', function(e, data) {
			console.log('coordinates: ' + data);
			if (data.stretch) {
				console.log('image too small!!!!');
			}
	});

Options

Option Type Default Required Description
width integer 320 no Width in pixels of the cropping window
height integer 180 no Height in pixels of the cropping window
zoom integer 10 no Number of incremental zoom steps. With the default of 10, you have to click the zoom-in button 9 times to reach 100%.
controls string/jquery null no If not null, this is the entire html block that should appear on hover over the image for instructions and/or buttons (could include the zoom in/out buttons for example). If null, the default html block is used which has the text "Click to drag" and the zoom in/out buttons. Use '' (or false) if you don't want anything to appear.

Event

To get crop results, bind a function on the crop event or read the object's result property (see below)

Advanced

A reference to the crop object can be accessed like so:

	var crop = $('img.crop').data('jQcrop');
	console.log(crop.results);

You then have access to all the properties and methods used for that specific element. Most important is that you can alter the width/height and have the plugin auto-recalculate the crop results and auto-resize:

	var crop = $('img.crop').data('jQcrop');
	crop.set({width: 300, height: 300});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.