historyDraggableBoundary.js 893 B

123456789101112131415161718192021222324252627282930313233
  1. import App from '../../../base'
  2. export default App.directive('historyDraggableBoundary', () => ({
  3. scope: {
  4. historyDraggableBoundary: '@',
  5. historyDraggableBoundaryOnDragStart: '&',
  6. historyDraggableBoundaryOnDragStop: '&',
  7. },
  8. restrict: 'A',
  9. link(scope, element, attrs) {
  10. element.data('selectionBoundary', {
  11. boundary: scope.historyDraggableBoundary,
  12. })
  13. element.draggable({
  14. axis: 'y',
  15. opacity: false,
  16. helper: 'clone',
  17. revert: true,
  18. scroll: true,
  19. cursor: 'row-resize',
  20. start(e, ui) {
  21. ui.helper.data('wasProperlyDropped', false)
  22. scope.historyDraggableBoundaryOnDragStart()
  23. },
  24. stop(e, ui) {
  25. scope.historyDraggableBoundaryOnDragStop({
  26. isValidDrop: ui.helper.data('wasProperlyDropped'),
  27. boundary: scope.historyDraggableBoundary,
  28. })
  29. },
  30. })
  31. },
  32. }))