Simple Image Viewer Plugin with CSS, JavaScript, and Canvas
Submitted by alpha_luna on Thursday, August 18, 2016 - 16:25.
Simple Image Viewer Plugin
In this tutorial, we are going to create Simple Image Viewer Plugin with CSS, JavaScript, and Canvas. Using ImageTrans.js is a simple plugin that can display any picture or image viewer. It can zoom in and out, flip to vertical or horizontal, and it has rotating features. You can also check the live demo of this simple tutorial, so you can get an idea and you can try this out, let's start coding.How to create it
- Create a simple markup for the container of the image and the buttons.
- <input id="Vertical_Image" type="button" class="btn" value="Vertical Flip" />
- <input id="Horizontal_Image" type="button" class="btn" value="Horizontal Flip" />
- <input id="Reset_Image" type="button" class="btn" value="Reset" />
- <input id="Canvas_Image" type="button" class="btn" value="Using Canvas" />
- <br />
- <br />
- <input id="image_address" type="text" class="form-control" placeholder="Enter the Image Address . . . . ." autofocus="autofocus">
- <br />
- <input id="view_Image" type="button" value="View" class="btn btn-primary">
- Using this simple script, we can initialize the image viewer to the default options.
- var it = $("#Image_Container").ImageTrans( options );
- These all the script for the feature of ImageTrans.js.
- it.load(src);
- $("#Zoom_Out_Image").on( "click", function(){ it.zoomout(); })
- $("#Zoom_In_Image").on( "click", function(){ it.zoomin(); })
- $("#Vertical_Image").on( "click", function(){
- it.vertical();
- } )
- $("#Horizontal_Image").on( "click", function(){
- it.horizontal();
- } )
- $("#Left_Image").on( "click", function(){
- it.left();
- })
- $("#Right_Image").on( "click", function(){ it.right(); })
- $("#Reset_Image").on( "click", function(){ it.reset(); })
- $("#view_Image").on( "click", function(){
- src = $("#image_address").val();
- it.load(src);
Output

Add new comment
- 99 views