Skip to content

Instantly share code, notes, and snippets.

@Robin-front
Forked from paullewis/requestIdleCallback.js
Created August 25, 2017 02:34
Show Gist options
  • Save Robin-front/bcdae44e22ab37de9a5dc7e9089002bb to your computer and use it in GitHub Desktop.
Save Robin-front/bcdae44e22ab37de9a5dc7e9089002bb to your computer and use it in GitHub Desktop.

Revisions

  1. @paullewis paullewis revised this gist Mar 24, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion requestIdleCallback.js
    Original file line number Diff line number Diff line change
    @@ -19,8 +19,8 @@
    */
    window.requestIdleCallback = window.requestIdleCallback ||
    function (cb) {
    var start = Date.now();
    return setTimeout(function () {
    var start = Date.now();
    cb({
    didTimeout: false,
    timeRemaining: function () {
  2. @paullewis paullewis revised this gist Oct 22, 2015. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion requestIdleCallback.js
    Original file line number Diff line number Diff line change
    @@ -19,11 +19,12 @@
    */
    window.requestIdleCallback = window.requestIdleCallback ||
    function (cb) {
    var start = Date.now();
    return setTimeout(function () {
    cb({
    didTimeout: false,
    timeRemaining: function () {
    return 50;
    return Math.max(0, 50 - (Date.now() - start));
    }
    });
    }, 1);
  3. @paullewis paullewis revised this gist Oct 21, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion requestIdleCallback.js
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ window.requestIdleCallback = window.requestIdleCallback ||
    cb({
    didTimeout: false,
    timeRemaining: function () {
    return Number.MAX_VALUE;
    return 50;
    }
    });
    }, 1);
  4. @paullewis paullewis revised this gist Oct 21, 2015. 1 changed file with 2 additions and 4 deletions.
    6 changes: 2 additions & 4 deletions requestIdleCallback.js
    Original file line number Diff line number Diff line change
    @@ -17,8 +17,7 @@
    /*
    * @see https://developers.google.com/web/updates/2015/08/using-requestidlecallback
    */
    window.requestIdleCallback =
    window.requestIdleCallback ||
    window.requestIdleCallback = window.requestIdleCallback ||
    function (cb) {
    return setTimeout(function () {
    cb({
    @@ -30,8 +29,7 @@ window.requestIdleCallback =
    }, 1);
    }

    window.cancelIdleCallback =
    window.cancelIdleCallback ||
    window.cancelIdleCallback = window.cancelIdleCallback ||
    function (id) {
    clearTimeout(id);
    }
  5. @paullewis paullewis revised this gist Oct 21, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions requestIdleCallback.js
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,9 @@
    * permissions and limitations under the License.
    */

    /*
    * @see https://developers.google.com/web/updates/2015/08/using-requestidlecallback
    */
    window.requestIdleCallback =
    window.requestIdleCallback ||
    function (cb) {
  6. @paullewis paullewis revised this gist Oct 21, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion requestIdleCallback.js
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ window.requestIdleCallback =
    function (cb) {
    return setTimeout(function () {
    cb({
    didTimeout:false,
    didTimeout: false,
    timeRemaining: function () {
    return Number.MAX_VALUE;
    }
  7. @paullewis paullewis created this gist Oct 20, 2015.
    34 changes: 34 additions & 0 deletions requestIdleCallback.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    /*!
    * Copyright 2015 Google Inc. All rights reserved.
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    * http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
    * or implied. See the License for the specific language governing
    * permissions and limitations under the License.
    */

    window.requestIdleCallback =
    window.requestIdleCallback ||
    function (cb) {
    return setTimeout(function () {
    cb({
    didTimeout:false,
    timeRemaining: function () {
    return Number.MAX_VALUE;
    }
    });
    }, 1);
    }

    window.cancelIdleCallback =
    window.cancelIdleCallback ||
    function (id) {
    clearTimeout(id);
    }