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


TypeScript Delay.setInterval函數代碼示例

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


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

示例1: function

  const animate = function (getCurrent, destination, amount, increment, doFinish, rate) {
    let finished = false;

    const finish = function (v) {
      finished = true;
      doFinish(v);
    };

    Delay.clearInterval(interval);

    const abort = function (v) {
      Delay.clearInterval(interval);
      finish(v);
    };

    interval = Delay.setInterval(function () {
      const value = getCurrent();
      adjust(value, destination, amount).fold(function () {
        Delay.clearInterval(interval);
        finish(destination);
      }, function (s) {
        increment(s, abort);
        if (! finished) {
          const newValue = getCurrent();
          // Jump to the end if the increment is no longer working.
          if (newValue !== s || Math.abs(newValue - destination) > Math.abs(value - destination)) {
            Delay.clearInterval(interval);
            finish(destination);
          }
        }
      });
    }, rate);
  };
開發者ID:tinymce,項目名稱:tinymce,代碼行數:33,代碼來源:SmoothAnimation.ts

示例2: function

  suite.test('clearTimeout', function () {
    let id;

    id = Delay.setInterval(function () {
      throw new Error('clearInterval didn\'t work.');
    });

    Delay.clearInterval(id);
    ok(true, 'clearInterval works.');
  });
開發者ID:abstask,項目名稱:tinymce,代碼行數:10,代碼來源:DelayTest.ts

示例3: storeDraft

const startStoreDraft = (editor: Editor, started: Cell<boolean>) => {
  const interval = Settings.getAutoSaveInterval(editor);

  if (!started.get()) {
    Delay.setInterval(() => {
      if (!editor.removed) {
        storeDraft(editor);
      }
    }, interval);

    started.set(true);
  }
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:13,代碼來源:Storage.ts

示例4: function

const onOrientationReady = function (outerWindow, refreshView) {
  // When rotating into portrait, the page (and toolbar) is off the top of the screen (pageYOffset > 0)
  // when the view settles, the toolbar will readjust to be visible/fixed to the top (pageYOffset = 0)
  // wait for the toolbar to recover before refreshing the view and scrolling cursor into view
  // done here instead of nomad toolbar fixup since that is tied to window scroll, which does not
  // fire on landscape
  const scrollNotZero = Delay.setInterval(function () {
    if (outerWindow.pageYOffset === 0) {
      Delay.clearInterval(scrollNotZero);
      refreshView();
    }
  }, 100);
};
開發者ID:tinymce,項目名稱:tinymce,代碼行數:13,代碼來源:IosHacks.ts

示例5: Promise

 init: (e) => new Promise((resolve) => {
   const intervalId = Delay.setInterval(() => {
     if (resolveInit.get()) {
       Delay.clearInterval(intervalId);
       Class.add(Element.fromDom(e), 'my-custom-editor');
       resolve({
         setValue(s) { customEditorValue.set(s); },
         getValue() { return customEditorValue.get(); },
         destroy() {}
       });
     }
   }, 500);
 })
開發者ID:tinymce,項目名稱:tinymce,代碼行數:13,代碼來源:BasicCustomEditorTest.ts

示例6: Promise

 return new Promise((resolve, reject) => {
   let numRetries = 3;
   const interval = Delay.setInterval(() => {
     if (hasLoaded()) {
       Delay.clearInterval(interval);
       resolve(true);
     } else {
       numRetries--;
       if (numRetries < 0) {
         console.log('Could not load emojis from url: ' + databaseUrl);
         Delay.clearInterval(interval);
         reject(false);
       }
     }
   }, 500);
 });
開發者ID:tinymce,項目名稱:tinymce,代碼行數:16,代碼來源:EmojiDatabase.ts

示例7: function

  const onAdjustment = function (f) {
    // If a developer is spamming orientation events in the simulator, clear our last check
    Delay.clearInterval(poller);

    const flag = outerWindow.innerHeight;
    let insurance = 0;
    poller = Delay.setInterval(function () {
      if (flag !== outerWindow.innerHeight) {
        Delay.clearInterval(poller);
        f(Option.some(outerWindow.innerHeight));
      } else if (insurance > INSURANCE) {
        Delay.clearInterval(poller);
        f(Option.none());
      }
      insurance++;
    }, INTERVAL);
  };
開發者ID:tinymce,項目名稱:tinymce,代碼行數:17,代碼來源:Orientation.ts

示例8: handleWindowResize

function handleWindowResize() {
  if (!Env.desktop) {
    let lastSize = {
      w: window.innerWidth,
      h: window.innerHeight
    };

    Delay.setInterval(function () {
      const w = window.innerWidth,
        h = window.innerHeight;

      if (lastSize.w !== w || lastSize.h !== h) {
        lastSize = {
          w,
          h
        };

        DomQuery(window).trigger('resize');
      }
    }, 100);
  }

  function reposition() {
    let i;
    const rect = DomUtils.getWindowSize();
    let layoutRect;

    for (i = 0; i < windows.length; i++) {
      layoutRect = windows[i].layoutRect();

      windows[i].moveTo(
        windows[i].settings.x || Math.max(0, rect.w / 2 - layoutRect.w / 2),
        windows[i].settings.y || Math.max(0, rect.h / 2 - layoutRect.h / 2)
      );
    }
  }

  DomQuery(window).on('resize', reposition);
}
開發者ID:danielpunkass,項目名稱:tinymce,代碼行數:39,代碼來源:Window.ts


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