當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript DragulaService.setOptions方法代碼示例

本文整理匯總了TypeScript中ng2-dragula/ng2-dragula.DragulaService.setOptions方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DragulaService.setOptions方法的具體用法?TypeScript DragulaService.setOptions怎麽用?TypeScript DragulaService.setOptions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ng2-dragula/ng2-dragula.DragulaService的用法示例。


在下文中一共展示了DragulaService.setOptions方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

 constructor( private _dragula: DragulaService) {
     this._dragula.setOptions('questions', {
         moves: function(el, container, handle:HTMLElement) {
             return handle.classList.contains('dragula-handle');
         }
     });
 }
開發者ID:mik-laj,項目名稱:bliski_publikator,代碼行數:7,代碼來源:questions.component.ts

示例2: constructor

 constructor (private wikipediaService: TestService, private dragulaServie: DragulaService) {
     dragulaServie.setOptions('first-bag', {
         cancel: true
     });
     
     
     
 }
開發者ID:Macio1992,項目名稱:angular2,代碼行數:8,代碼來源:test.component.ts

示例3: constructor

 constructor(private drag: DragulaService) {
   this.byteExtracts = 0;
   drag.setOptions('rule-patterns', {
     moves: function (el, container, handle) {
       return handle.className === 'material-icons';
     }
   });
 }
開發者ID:eSentire,項目名稱:old-major,代碼行數:8,代碼來源:rule-patterns.component.ts

示例4: constructor

  constructor(private routeParams: RouteParams, private af: AngularFire, private dragulaService: DragulaService) {
    af.auth.asObservable().filter(user => user !== null).subscribe(user => { // Skip null values
      this.boardURL = 'users/' + user.uid + '/boards/' + routeParams.get('key');
      this.board = af.object(this.boardURL);
      this.lists = af.list(this.boardURL + '/lists', { query: { orderByChild: 'priority' } });
      this.tasks = af.list(this.boardURL + '/tasks', { query: { orderByChild: 'priority' } });

      this.listObservable = af.list(this.boardURL + '/lists');
      this.taskObservable = af.list(this.boardURL + '/tasks');
    });

    // The outer list can only be dragged by a handle. To prevent overlapping drag boxes.
    dragulaService.setOptions('listBag', {
      moves: function (el, container, handle) {
        return handle.className === 'handle';
      }
    });

    dragulaService.drop.subscribe(([bag, element, target, source, next]) => {
      // Look at the adjacent tasks in the list and pick a priority in the middle
      let prev = element.previousElementSibling;

      if (bag === 'taskBag') {
        let observables: Observable<Task>[] = [Observable.of(undefined), Observable.of(undefined), Observable.of(undefined)];
        // Get the keys from the DOM. Stored in data-key attributes.
        if (prev != null && prev.className === 'task') observables[0] = (af.object(this.boardURL + '/tasks/' + prev.dataset.key));
        if (element != null && element.className === 'task') observables[1] = (af.object(this.boardURL + '/tasks/' + element.dataset.key));
        if (next != null && next.className === 'task') observables[2] = (af.object(this.boardURL + '/tasks/' + next.dataset.key));

        Observable.zip(...observables) // Combine the observables then subscribe asynchronously
          .take(1) // only subscribe once
          .subscribe(([previousTask, movedTask, nextTask]: Task[]) => {
            let lower = -4; // arbitrary
            let upper = 4;  // arbitrary
            if (previousTask && previousTask.priority != null) {
              lower = previousTask.priority;
            } else if (nextTask && nextTask.priority != null) {
              lower = nextTask.priority - 4;
            }
            if (nextTask && nextTask.priority != null) {
              upper = nextTask.priority;
            } else if (previousTask && previousTask.priority != null) {
              upper = previousTask.priority + 4;
            }
            // Update the priority of the moved task in the database
            movedTask.priority = lower + (Math.abs(upper - lower) / 2);
            // Check if it swapped to a different list
            if (target.dataset.key !== source.dataset.key) {
              movedTask.list = target.dataset.key;
            }
            this.taskObservable.update(element.dataset.key, movedTask);
          });
      } else if (bag === 'listBag') {
        // TODO reorder the lists, similar as above
      }
    });
  }
開發者ID:Denhai,項目名稱:everyday-butter,代碼行數:57,代碼來源:board.component.ts

示例5: ngOnInit

 ngOnInit() {
   this.dragulaModel = this.publishFreeReorder.files;
   this.myDragula.setOptions(UUID.UUID(), {
     moves: (el: Element, source: Element, handle: Element) => {
       return handle.classList.contains('drag-handle');
     }
   });
   this.dragSub = this.myDragula.dropModel.subscribe(() => {
     this.publishFreeReorder.reassign();
   });
   super.ngOnInit();
 }
開發者ID:PRX,項目名稱:publish.prx.org,代碼行數:12,代碼來源:free-reorder.directive.ts

示例6: constructor

  constructor( private dragulaService: DragulaService) {
    this.leftColor = '#F44336';
    this.rightColor = '#D32F2F';
    this.textColor = '#FFFFFF';
    this.leftPoints = '125,30 125,30 125,30 31.9,63.2 46.1,186.3 125,230 125,230 125,230 203.9,186.3 218.1,63.2';
    this.rightPoints = '125,30 125,52.2 125,52.1 125,153.4 125,153.4 125,230 125,230 203.9,186.3 218.1,63.2 125,30';
    this.textD = 'M125,52.1L66.8,182.6h0h21.7h0l11.7-29.2h49.4l11.7,29.2h0h21.7h0L125,52.1L125,52.1L125,52.1L125,52.1L125,52.1z M142,135.4H108l17-40.9L142,135.4z';

    dragulaService.setOptions('shield', {
      moves: function (el, source, handle, sibling) {
        switch (el.id) {
          case 'left':
          case 'right':
          case 'text':
            return false;
          default:
            return true;
        }
      },
      accepts: function (el, target, source, sibling) {
        switch (target.id) {
          case 'left':
          case 'right':
          case 'text':
            return true;
          default:
            return false;
        }
      },
      copy: true
    });

    dragulaService.drag.subscribe((value) => {
      this.colorDragging = true;
    });

    dragulaService.over.subscribe((value) => {
      this.onOver(value.slice(1));
    });

    dragulaService.out.subscribe((value) => {
      this.onOut(value.slice(1));
    });

    dragulaService.drop.subscribe((value) => {
      this.colorDragging = false;
      this.buttonClicked = false;
      this.onDrop(value.slice(1));
    });
  }
開發者ID:dweitz43,項目名稱:ng-logo,代碼行數:50,代碼來源:logo.component.ts

示例7: initializeDragAndDrop

  public initializeDragAndDrop(
    dragulaService: DragulaService,
    dropCallback: (newColumnIds: Array<string>) => void) {
    dragulaService.drag.subscribe(([, source]: Array<HTMLElement>) =>
      source.classList.add(GRID_HEADER_DRAGGING_CLASS)
    );

    dragulaService.dragend.subscribe(([, source]: Array<HTMLElement>) =>
      source.classList.remove(GRID_HEADER_DRAGGING_CLASS)
    );

    dragulaService.drop.subscribe(([, , container]: Array<HTMLElement>) => {
      let columnIds: string[] = [];
      let nodes = container.getElementsByTagName('th');
      for (let i = 0; i < nodes.length; i++) {
        let el = nodes[i];
        let id = el.getAttribute('sky-cmp-id');
        columnIds.push(id);
      }
      dropCallback(columnIds);

    });

    dragulaService.setOptions('sky-grid-heading', {
      moves: (el: HTMLElement, container: HTMLElement, handle: HTMLElement) => {
        return !handle.matches(GRID_HEADER_LOCKED_SELECTOR);
      },
      accepts: (
        el: HTMLElement,
        target: HTMLElement,
        source: HTMLElement,
        sibling: HTMLElement) => {
          return sibling === undefined || !sibling || !sibling.matches(GRID_HEADER_LOCKED_SELECTOR);
        }
    });
  }
開發者ID:Blackbaud-DanHamlin,項目名稱:skyux2,代碼行數:36,代碼來源:grid-adapter.service.ts

示例8: constructor

 constructor(private dragulaService: DragulaService) {
     dragulaService.setOptions('third-bag', {
         removeOnSpill: true
     });
 }
開發者ID:crisipix,項目名稱:Angular2WebpackBasicTemplate,代碼行數:5,代碼來源:dragula.component.ts


注:本文中的ng2-dragula/ng2-dragula.DragulaService.setOptions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。