بک لینک

موضوع بسته شده است 
حرکت اجسام در صفحه
#8
من خودم از این روش استفاده کردم ولی جواب نداد
کد:
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script>

$(document).ready(function (){
(function($) {
    $.fn.drags = function(opt) {

        opt = $.extend({handle:"",cursor:"move"}, opt);

        if(opt.handle === "") {
            var $el = this;
        } else {
            var $el = this.find(opt.handle);
        }

        return $el.css('cursor', opt.cursor).on("mousedown", function(e) {
            if(opt.handle === "") {
                var $drag = $(this).addClass('draggable');
            } else {
                var $drag = $(this).addClass('active-handle').parent().addClass('draggable');
            }
            var z_idx = $drag.css('z-index'),
                drg_h = $drag.outerHeight(),
                drg_w = $drag.outerWidth(),
                pos_y = $drag.offset().top + drg_h - e.pageY,
                pos_x = $drag.offset().left + drg_w - e.pageX;
            $drag.css('z-index', 1000).parents().on("mousemove", function(e) {
                $('.draggable').offset({
                    top:e.pageY + pos_y - drg_h,
                    left:e.pageX + pos_x - drg_w
                }).on("mouseup", function() {
                    $(this).removeClass('draggable').css('z-index', z_idx);
                });
            });
            e.preventDefault(); // disable selection
        }).on("mouseup", function() {
            if(opt.handle === "") {
                $(this).removeClass('draggable');
            } else {
                $(this).removeClass('active-handle').parent().removeClass('draggable');
            }
        });

    }
})(jQuery);

$('.myclass').drags();
});
</script>
<script>
x=documetn.getElementById('1')
if (x.style.margin>30px){
x.style.margin="30px";
}
</script>
<style>
.myclass{
  width: 100px;
  height: 100px;
  line-height: 100px;
  text-align: center;
  background: red;
  color: white;
  position: absolute;
  left: 20px;
  top: 20px;
}
body {
}
</style>
<body>

<div class="myclass" id="1">Drag me</div>        
</body>
در حال برنامه نویسی یک اسکریپت هستم...|منتظر باشید 
موضوع بسته شده است 


پیام‌های داخل این موضوع
حرکت اجسام در صفحه - Mr.Navid - 93-9-28، 03:03 صبح
RE: حرکت اجسام در صفحه - Mr.Navid - 93-10-1، 05:22 عصر

پرش به انجمن:


کاربرانِ درحال بازدید از این موضوع: 1 مهمان