• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ng2-dragula.DragulaService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中ng2-dragula/ng2-dragula.DragulaService的典型用法代码示例。如果您正苦于以下问题:TypeScript DragulaService类的具体用法?TypeScript DragulaService怎么用?TypeScript DragulaService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DragulaService类的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: 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


示例6: 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


示例7: constructor

 constructor(private dragulaService: DragulaService) {
     dragulaService.setOptions('third-bag', {
         removeOnSpill: true
     });
 }
开发者ID:crisipix,项目名称:Angular2WebpackBasicTemplate,代码行数:5,代码来源:dragula.component.ts


示例8: 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



注:本文中的ng2-dragula/ng2-dragula.DragulaService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ng2-facebook-sdk.FacebookService类代码示例发布时间:2022-05-25
下一篇:
TypeScript ng2-cookies.Cookie类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap