AngularUI modal to be draggable and resizable

前端 未结 6 494
逝去的感伤
逝去的感伤 2021-02-04 02:19

I have an angularUi modal window wrapped in a directive:

html:



  
    

        
6条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-04 03:09

    Thank you for your examples. I little bit polished your code and this is my final result. to my solution it works perfectly :-)

    HTML:

    angular.module('posProductsManager').directive('modalDialog', function () { var definition = { restrict: 'AC', link: function ($scope, element) { var draggableStr = "draggableModal"; var header = $(".modal-header", element); var modalDialog = element; var clickPosition = null; var clickOffset = null; header[0].addEventListener('mousedown', function (position) { clickPosition = position; clickOffset = position; window.addEventListener('mouseup', mouseUpEvent); window.addEventListener('mousemove', mouseMoveEvent); }); function mouseUpEvent() { clickPosition = null; window.removeEventListener('mouseup', mouseUpEvent); window.removeEventListener('mousemove', mouseMoveEvent); } function mouseMoveEvent(position) { var offset = modalDialog.parents().offset(); $("." + draggableStr, modalDialog.parents()).offset({ left: clickPosition.pageX + (position.pageX - clickPosition.pageX) - clickOffset.offsetX, top: clickPosition.pageY + (position.pageY - clickPosition.pageY) - clickOffset.offsetY, }); clickPosition = position; } } }; return definition; });

提交回复
热议问题