달력

52024  이전 다음

  • 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

DIV draggable

Script 이야기 2015. 11. 18. 18:37
<script src="~/resource/common/js/jquery-ui.min.js"></script>
 
<script>
    //div draggable 처리
    (function (b)
    {
        b.support.touch = "ontouchend" in document;
 
        if (!b.support.touch) { return; }
 
        var c = b.ui.mouse.prototype,
            e = c._mouseInit,
            a;
 
        function d(g, h)
        {
            if (g.originalEvent.touches.length > 1)
            {
                return;
            }
 
            g.preventDefault();
 
            var i = g.originalEvent.changedTouches[0],
                f = document.createEvent("MouseEvents");
 
            f.initMouseEvent(h, true, true, window, 1, i.screenX, i.screenY, i.clientX, i.clientY, false, false, false, false, 0, null);
 
            g.target.dispatchEvent(f);
        }
 
        c._touchStart = function (g)
        {
            var f = this;
 
            if (|| !f._mouseCapture(g.originalEvent.changedTouches[0]))
            {
                return;
            }
 
            a = true;
 
            f._touchMoved = false;
 
            d(g, "mouseover");
            d(g, "mousemove");
            d(g, "mousedown");
        };
        c._touchMove = function (f)
        {
            if (!a)
                return;
 
            this._touchMoved = true;
 
            d(f, "mousemove");
        };
        c._touchEnd = function (f)
        {
            if (!a)
                return;
 
            d(f, "mouseup");
            d(f, "mouseout");
 
            if (!this._touchMoved)
            {
                d(f, "click");
            }
 
            a = false;
        };
 
        c._mouseInit = function ()
        {
            var f = this;
 
            f.element
            .bind("touchstart", b.proxy(f, "_touchStart"))
            .bind("touchmove", b.proxy(f, "_touchMove"))
            .bind("touchend", b.proxy(f, "_touchEnd"));
 
            e.call(f);
        };
    })(jQuery);
 
    $(function ()
    {
       $(".draggable").draggable();
    });
</script>

하이브리드 앱에서 플로팅 이미지 이동 처리를 할 때 사용함.

Posted by 은하비류연
|