 
						Pure javascript
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | window.onload = function() {    varoptions =    {        imageBox: '.imageBox',        thumbBox: '.thumbBox',        spinner: '.spinner',        imgSrc: 'avatar.png'    }    varcropper = newcropbox(options);    document.querySelector('#file').addEventListener('change', function(){        varreader = newFileReader();        reader.onload = function(e) {            options.imgSrc = e.target.result;            cropper = newcropbox(options);        }        reader.readAsDataURL(this.files[0]);        this.files = [];    })    document.querySelector('#btnCrop').addEventListener('click', function(){        varimg = cropper.getDataURL()        document.querySelector('.cropped').innerHTML += '<img src="'+img+'">';    })    document.querySelector('#btnZoomIn').addEventListener('click', function(){        cropper.zoomIn();    })    document.querySelector('#btnZoomOut').addEventListener('click', function(){        cropper.zoomOut();    })}; | 
Jquery plugin
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | $(window).load(function() {    varoptions =    {        thumbBox: '.thumbBox',        spinner: '.spinner',        imgSrc: 'avatar.png'    }    varcropper = $('.imageBox').cropbox(options);    $('#file').on('change', function(){        varreader = newFileReader();        reader.onload = function(e) {            options.imgSrc = e.target.result;            cropper = $('.imageBox').cropbox(options);        }        reader.readAsDataURL(this.files[0]);        this.files = [];    })    $('#btnCrop').on('click', function(){        varimg = cropper.getDataURL()        $('.cropped').append('<img src="'+img+'">');    })    $('#btnZoomIn').on('click', function(){        cropper.zoomIn();    })    $('#btnZoomOut').on('click', function(){        cropper.zoomOut();    })});// use with require js (new feature added on 9 Oct 2014)require.config({    baseUrl: "../",    paths: {        jquery: 'jquery-1.11.1.min',        cropbox: 'cropbox'    }});require( ["jquery", "cropbox"], function($) {    varoptions =    {        thumbBox: '.thumbBox',        spinner: '.spinner',        imgSrc: 'avatar.png'    }    varcropper = $('.imageBox').cropbox(options);    $('#file').on('change', function(){        varreader = newFileReader();        reader.onload = function(e) {            options.imgSrc = e.target.result;            cropper = $('.imageBox').cropbox(options);        }        reader.readAsDataURL(this.files[0]);        this.files = [];    })    $('#btnCrop').on('click', function(){        varimg = cropper.getDataURL();        $('.cropped').append('<img src="'+img+'">');    })    $('#btnZoomIn').on('click', function(){        cropper.zoomIn();    })    $('#btnZoomOut').on('click', function(){        cropper.zoomOut();    })    }); | 
YUI plugin
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | YUI().use('node', 'crop-box', function(Y){    varoptions =    {        imageBox: '.imageBox',        thumbBox: '.thumbBox',        spinner: '.spinner',        imgSrc: 'avatar.png'    }    varcropper = newY.cropbox(options);    Y.one('#file').on('change', function(){        varreader = newFileReader();        reader.onload = function(e) {            options.imgSrc = e.target.result;            cropper = newY.cropbox(options);        }        reader.readAsDataURL(this.get('files')._nodes[0]);        this.get('files')._nodes = [];    })    Y.one('#btnCrop').on('click', function(){        varimg = cropper.getDataURL()        Y.one('.cropped').append('<img src="'+img+'">');    })    Y.one('#btnZoomIn').on('click', function(){        cropper.zoomIn();    })    Y.one('#btnZoomOut').on('click', function(){        cropper.zoomOut();    })}) | 
特别申明:
			本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
			本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
			如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com