Scroll the page to a particular page anchor
@param {HTMLElement} to The element to scroll to.
@param {number} offset A scrolling offset.
@param {function} callback Function to apply after scrolling
@return {void}
554550
function scrollPage(to, offset, callback) {
  if ( offset === void 0 ) offset = 0;

  var startTime;
  var duration = 500;
  var startPos = window.pageYOffset;
  var endPos = ~~(to.getBoundingClientRect().top - offset);
  var scroll = function (timestamp) {
    var elapsed;

    startTime = startTime || timestamp;
    elapsed = timestamp - startTime;

    document.body.scrollTop = document.documentElement.scrollTop = easeInOutCubic(elapsed, startPos, endPos, duration);

    if (elapsed < duration) {
      requestAnimationFrame(scroll);
    } else if (callback) {
      callback.call(to);
    }
  };

  requestAnimationFrame(scroll);
}
1371880
function offset ( elem, orientation ) {

        var rect = elem.getBoundingClientRect(),
            doc = elem.ownerDocument,
            docElem = doc.documentElement,
            pageOffset = getPageOffset();

        // getBoundingClientRect contains left scroll in Chrome on Android.
        // I haven't found a feature detection that proves this. Worst case
        // scenario on mis-match: the 'tap' feature on horizontal sliders breaks.
        if ( /webkit.*Chrome.*Mobile/i.test(navigator.userAgent) ) {
            pageOffset.x = 0;
        }

        return orientation ? (rect.top + pageOffset.y - docElem.clientTop) : (rect.left + pageOffset.x - docElem.clientLeft);
    }
430341
function ScrollToggle(el, config) {
  this.el_ = el;

  this.config_ = objects.clone(config);
  if (this.el_.hasAttribute('data-ak-scrolltoggle')) {
    var elConfig = JSON.parse(this.el_.getAttribute('data-ak-scrolltoggle'));
    if (elConfig && typeof elConfig === 'object') {
      objects.merge(this.config_, elConfig);
    }
  }

  // Initialize the current scroll position.
  this.lastScrollPos_ = 0;
  this.onScroll();
}
1356277
function(duration, callback) {
      return this.each(function(index, el) {
        u(el).scrollTo(0, duration, callback);
      });
    }
735842
function(element, callback, nowait) {
    var self = this;
    if (!nowait) {
      this.waitForPage(function() {
        self.waitForElement(element, callback, true);
      });
    }
    else {
      var loadWait = function() {
        setTimeout(function() {
          self.waitForElement(element, callback, true);
        }, 100);
      };
      if (nowait) {
        getPage(function(page) {
          page.evaluate(function(element) {
            var element = jQuery(element);
            return ((element.length > 0) && element.is(':visible'));
          }, function(found) {
            if (found) {
              self.debug('Element ' + element + ' found');
              callback.call(self);
            }
            else {
              loadWait();
            }
          }, element);
        });
      }
      else {
        loadWait();
      }
    }
  }
1115163
function scrollTo() {
      var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
      var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
      var time = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : this.bounceTime;
      this.scroll && this.scroll.scrollTo(x, y, time);
    }
893795
function delegate(callback, el) {
        var currentElement = el;

        do {
            if (!isClickTarget(currentElement)) continue;
            callback(currentElement);
            return;
        } while(currentElement.nodeName.toUpperCase() !== 'BODY' && (currentElement = currentElement.parentNode));
    }
1173060
function scrollToTop() {
  const c = document.documentElement.scrollTop || document.body.scrollTop;

  if (c > 0) {
    window.requestAnimationFrame(scrollToTop);
    window.scrollTo(0, c - c / 8);
  }
}
226065
protected void detectOutOfScopeElement(Element element, Functions.Func callback) {
        if (scrollHelper.isInViewPort(element)) {
            callback.call();
        } else {
            scrollHelper.setOffsetPosition(OffsetPosition.MIDDLE);
            scrollHelper.setCompleteCallback(() -> callback.call());
            scrollHelper.scrollTo(element);
        }
    }
274424
function checkScroll() {
            if (window.pageXOffset != scroll.left) {
                scroll.top = window.pageYOffset;
                scroll.left = window.pageXOffset;
    
                Stickyfill.refreshAll();
            } else if (window.pageYOffset != scroll.top) {
                scroll.top = window.pageYOffset;
                scroll.left = window.pageXOffset;
    
                // recalc position for all stickies
                stickies.forEach(function (sticky) {
                    return sticky._recalcPosition();
                });
            }
        }
307317
function(callback, nowait) {
    var self = this;
    var loadWait = function() {
      setTimeout(function() {
        self.waitForPage(callback, true);
      }, 100);
    };
    if (nowait) {
      if (loading) {
        loadWait();
      }
      else {
        getPage(function(page) {
          page.evaluate(function() {
            return jQuery.isReady;
          }, function(ready) {
            if (ready) {
              callback.call(self);
            }
            else {
              loadWait();
            }
          });
        });
      }
    }
    else {
      loadWait();
    }
  }
184409
function() {
        var isWindow = this.container.is(window),
            eTop = this.element.offset().top,
            offset,
            offsets = [];

        if (this.element.css('overflow') === 'auto' && !this.element.is('body')) {
            this.element[0].scrollTop = 0; // Set scroll to top so offsets are correct
        }

        this.targets = $(this.options.target);

        this.markers = $(this.options.marker).each(function(index, marker) {
            offset = $(marker).offset();

            if (!isWindow) {
                offset.top -= eTop;
            }

            offsets.push(offset);
        });

        this.offsets = offsets;
    }
383209
function onScroll(cb) {
  var isTicking = false;
  var scrollY = 0;
  var body = document.body;
  var html = document.documentElement;
  var scrollHeight = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
  function scroll() {
    scrollY = window.scrollY;
    if (cb) cb(scrollY, scrollHeight);
    requestTick();
  }
  function requestTick() {
    if (!isTicking) requestAnimationFrame(updateScroll);
    isTicking = true;
  }
  function updateScroll() {
    isTicking = false;
    var currentScrollY = scrollY;
  }
  scroll();
  window.onscroll = scroll;
}
139574
function() {
		this.scrollToCurrent();
		window.addEventListener('hashchange', this.scrollToCurrent.bind(this));
		document.body.addEventListener('click', this.delegateAnchors.bind(this));
	  }
73835
function(offset){
            if(arguments.length > 0){
                this.each(function(inx,ele){
                    var node = vQ(ele);
                    var coords = node.offset(),
                        parentOffset = ele.offsetParent.offset(),
                        props = {
                            top: coords.top - parentOffset.top,
                            left: coords.left - parentOffset.left
                        };
                    if (node.css('position') == 'static'){
                        props['position'] = 'relative';
                    }
                    node.css(props);
                });
            }
            if (!this.length) return null;
            if (!vQ.contains(document.documentElement, this[0]))
                return {top: 0, left: 0};
            var obj = this[0].getBoundingClientRect();
            return {
                left: obj.left + window.pageXOffset,
                top: obj.top + window.pageYOffset,
                width: Math.round(obj.width),
                height: Math.round(obj.height)
            };
        }
244870
public static void apply(String selector, Functions.Func callback) {
        apply($(selector).asElement(), 100, callback);
    }
1215788
function pageHasChanged(page, oldUrl, callback) {
    var elapsed = 0;

    var newUrl;
    var urlHasChanged = false;
    var documentReady = false;
    var waitTimeOver = false;

    async.until(
        function () {
            waitTimeOver = elapsed > constants.WAIT_TIMEOUT;
            return waitTimeOver || documentReady;
        },

        function (callback) {
            // polls the page at an interval
            setTimeout(function () {
                elapsed += constants.POLL_INTERVAL;

                async.waterfall([
                    function (callback) {
                        // checks the url
                        page.get('url', function (url) {
                            newUrl = url;
                            urlHasChanged = newUrl !== oldUrl;

                            callback();
                        })
                    },
                    function (callback) {
                        if (!urlHasChanged) {
                            callback();
                            return;
                        }

                        // checks the document.readyState
                        page.evaluate(function () {
                            return (document.readyState === 'interactive') || (document.readyState === 'complete');
                        }, function (domReady) {
                            documentReady = domReady;
                            callback();
                        });
                    }
                ], function (error) {
                    // no error is triggered
                    callback();
                });
            }, constants.POLL_INTERVAL);
        },

        function (error) {
            if (waitTimeOver) {
                // todo Go back to previous url?
                callback('Timeout while navigating to ' + url);
                return;
            }

            callback();
        }
    );
}