php - How to save image position after drag -


i new jquery have design custom shape image frame image dragging. able retrieve values of "top" , "left" positions. not able store position permanent after image draging. don't know how posibble without using database. below code test.php

<script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> <script> $(function() {     $(".headerimage").css('cursor', 'pointer');     var y1 = $('.picturecontainer').height();     var y2 = $('.headerimage').height();     var x1 = $('.picturecontainer').width();     var x2 = $('.headerimage').width();     $(".headerimage").draggable({         scroll: false,         containment: "#picturecontainer",         drag: function(event, ui) {             document.getelementbyid("img_top").value = ui.position.top;             document.getelementbyid("img_left").value = ui.position.left;             if (ui.position.top >= 0)             {                 ui.position.top = 0;             }             else if (ui.position.top <= y1 - y2)             {                 ui.position.top = y1 - y2;             }             else if (ui.position.left <= x1 - x2)             {                 ui.position.left = x1 - x2;             }         },         stop: function(event, ui) {             //####         }     }); }); 

<style>     .picturecontainer{         overflow: hidden;          position: relative;          width: 350px;          height: 350px;          background: #d3d3d3;         /*    border: 1px solid #888;*/         background-size:cover;         -webkit-shape-outside: polygon(0% 60%, 100% 0%, 100% 100%, 0% 100%);         shape-outside: polygon(0% 60%, 100% 0%, 100% 100%, 0% 100%);         -webkit-clip-path: polygon(0% 60%, 100% 0%, 100% 100%, 0% 100%);         -webkit-shape-margin: 20px;     } </style>  <h2>example 1</h2> <div class="ui-widget-content" style="padding:10px;">     top : <input type="text" name="img_top" id="img_top" value="" /><br />     left : <input type="text" name="img_left" id="img_left" value="" /><br />     <div class="picturecontainer" style="">         <img style="position: absolute;" class="headerimage ui-corner-all" src="img/1.jpg" />         <br />     </div>     <input id="saveimage" type="button" value="save" /> </div> 

you have use server-side script , save values database, these two

document.getelementbyid("img_top").value = ui.position.top; document.getelementbyid("img_left").value = ui.position.left; 

will retrieve values.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -