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


TypeScript dragdrop.IDragEvent類代碼示例

本文整理匯總了TypeScript中@phosphor/dragdrop.IDragEvent的典型用法代碼示例。如果您正苦於以下問題:TypeScript IDragEvent類的具體用法?TypeScript IDragEvent怎麽用?TypeScript IDragEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: _evtDrop

 /**
  * Handle the `'p-drop'` event for the widget.
  */
 private _evtDrop(event: IDragEvent): void {
   if (this.editor.getOption('readOnly') === true) {
     return;
   }
   const data = Private.findTextData(event.mimeData);
   if (data === undefined) {
     return;
   }
   this.removeClass(DROP_TARGET_CLASS);
   event.preventDefault();
   event.stopPropagation();
   if (event.proposedAction === 'none') {
     event.dropAction = 'none';
     return;
   }
   const coordinate = {
     top: event.y,
     bottom: event.y,
     left: event.x,
     right: event.x,
     x: event.x,
     y: event.y,
     width: 0,
     height: 0
   };
   const position = this.editor.getPositionForCoordinate(coordinate);
   const offset = this.editor.getOffsetAt(position);
   this.model.value.insert(offset, data);
 }
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:32,代碼來源:widget.ts

示例2: _evtDragLeave

 /**
  * Handle the `'p-dragleave'` event for the widget.
  */
 private _evtDragLeave(event: IDragEvent): void {
   event.preventDefault();
   event.stopPropagation();
   let dropTarget = DOMUtils.findElement(this.node, DROP_TARGET_CLASS);
   if (dropTarget) {
     dropTarget.classList.remove(DROP_TARGET_CLASS);
   }
 }
開發者ID:cameronoelsen,項目名稱:jupyterlab,代碼行數:11,代碼來源:crumbs.ts

示例3: _evtDragEnter

 /**
  * Handle the `'p-dragenter'` event for the widget.
  */
 private _evtDragEnter(event: IDragEvent): void {
   if (event.mimeData.hasData(CONTENTS_MIME)) {
     let index = ArrayExt.findFirstIndex(this._crumbs, node => ElementExt.hitTest(node, event.clientX, event.clientY));
     if (index !== -1) {
       if (index !== Private.Crumb.Current) {
         this._crumbs[index].classList.add(DROP_TARGET_CLASS);
         event.preventDefault();
         event.stopPropagation();
       }
     }
   }
 }
開發者ID:cameronoelsen,項目名稱:jupyterlab,代碼行數:15,代碼來源:crumbs.ts

示例4: _evtDragLeave

 /**
  * Handle the `'p-dragleave'` event for the widget.
  */
 private _evtDragLeave(event: IDragEvent): void {
   this.removeClass(DROP_TARGET_CLASS);
   if (this.editor.getOption('readOnly') === true) {
     return;
   }
   const data = Private.findTextData(event.mimeData);
   if (data === undefined) {
     return;
   }
   event.preventDefault();
   event.stopPropagation();
 }
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:15,代碼來源:widget.ts

示例5: _evtDragEnter

 /**
  * Handle the `'p-dragenter'` event for the widget.
  */
 private _evtDragEnter(event: IDragEvent): void {
   if (this.editor.getOption('readOnly') === true) {
     return;
   }
   const data = Private.findTextData(event.mimeData);
   if (data === undefined) {
     return;
   }
   event.preventDefault();
   event.stopPropagation();
   this.addClass('jp-mod-dropTarget');
 }
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:15,代碼來源:widget.ts

示例6: _evtDragOver

 /**
  * Handle the `'p-dragover'` event for the widget.
  */
 private _evtDragOver(event: IDragEvent): void {
   event.preventDefault();
   event.stopPropagation();
   event.dropAction = event.proposedAction;
   let dropTarget = DOMUtils.findElement(this.node, DROP_TARGET_CLASS);
   if (dropTarget) {
     dropTarget.classList.remove(DROP_TARGET_CLASS);
   }
   let index = ArrayExt.findFirstIndex(this._crumbs, node => ElementExt.hitTest(node, event.clientX, event.clientY));
   if (index !== -1) {
     this._crumbs[index].classList.add(DROP_TARGET_CLASS);
   }
 }
開發者ID:cameronoelsen,項目名稱:jupyterlab,代碼行數:16,代碼來源:crumbs.ts

示例7: _evtDrop

  /**
   * Handle the `'p-drop'` event for the widget.
   */
  private _evtDrop(event: IDragEvent): void {
    event.preventDefault();
    event.stopPropagation();
    if (event.proposedAction === 'none') {
      event.dropAction = 'none';
      return;
    }
    if (!event.mimeData.hasData(CONTENTS_MIME)) {
      return;
    }
    event.dropAction = event.proposedAction;

    let target = event.target as HTMLElement;
    while (target && target.parentElement) {
      if (target.classList.contains(DROP_TARGET_CLASS)) {
        target.classList.remove(DROP_TARGET_CLASS);
        break;
      }
      target = target.parentElement;
    }

    // Get the path based on the target node.
    let index = ArrayExt.findFirstIndex(this._crumbs, node => node === target);
    if (index === -1) {
      return;
    }

    const model = this._model;
    const path = PathExt.resolve(model.path, BREAD_CRUMB_PATHS[index]);
    const manager = model.manager;

    // Move all of the items.
    let promises: Promise<any>[] = [];
    let oldPaths = event.mimeData.getData(CONTENTS_MIME) as string[];
    for (let oldPath of oldPaths) {
      let localOldPath = manager.services.contents.localPath(oldPath);
      let name = PathExt.basename(localOldPath);
      let newPath = PathExt.join(path, name);
      promises.push(renameFile(manager, oldPath, newPath));
    }
    Promise.all(promises).catch(err => {
      showErrorMessage('Move Error', err);
    });
  }
開發者ID:7125messi,項目名稱:jupyterlab,代碼行數:47,代碼來源:crumbs.ts


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