add photo-wallpaper image-editor example

This commit is contained in:
Martin
2017-08-01 12:00:22 +02:00
parent 99a3efa956
commit c8816b3968
+36
View File
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<label>Width: <input type="text" id="width" name="width" value="500" /></label>
<label>Height: <input type="text" id="height" name="height" value="400" /></label>
<canvas id="image-editor" width="800" height="600"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.7.11/fabric.js"></script>
<script src="../../dist/js/main.js"></script>
<script type="text/javascript">
var width = document.getElementById('width');
var height = document.getElementById('height');
var editor = new ImageEditor('image-editor', {
type: 'photo-wallpaper',
dimensions: {width: 800, height: 600}
});
function cropImage() {
editor.crop(width.value, height.value, 'cm');
}
//add event listeners
width.addEventListener('keyup', cropImage);
height.addEventListener('keyup', cropImage);
//load the image
var image_url = '//images-dev.photowall.com/products/45825.jpg?h=450';
editor.loadImage(image_url, function() {
cropImage();
});
</script>
</body>
</html>