checkPosition method

void checkPosition()

Implementation

void checkPosition() {
  if (p.isHidden(element))
    return;

  final offsetTop = this.offsetTop() ?? _defaultOffset,
    offsetBottom = this.offsetBottom() ?? _defaultOffset,
    scrollHeight = $document().height!,
    scrollTop = window.pageYOffset,
    positionTop = element.offsetTop,
    affix = _unpin != null && scrollTop + _unpin! <= positionTop ? 'false' :
      (positionTop + element.offsetHeight >= scrollHeight - offsetBottom) ? 'bottom' :
      scrollTop <= offsetTop ? 'top' : 'false';

  if (_affixed == affix)
    return;
  _affixed = affix;
  _unpin = affix == 'bottom' ? positionTop - scrollTop : null;

  element.classes
  ..remove('affix')
  ..remove('affix-top')
  ..remove('affix-bottom')
  ..add(affix == 'bottom' ? 'affix-bottom' : affix == 'top' ? 'affix-top' : 'affix');

}