FIXME maybe add a margin around viewport to prevent too many updates
11047
function updateMarks(editor, diff, state, type, classes) {
    var vp = editor.getViewport();
    editor.operation(function() {
      if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
        clearMarks(editor, state.marked, classes);
        markChanges(editor, diff, type, state.marked, vp.from, vp.to, classes);
        state.from = vp.from; state.to = vp.to;
      } else {
        if (vp.from < state.from) {
          markChanges(editor, diff, type, state.marked, vp.from, state.from, classes);
          state.from = vp.from;
        }
        if (vp.to > state.to) {
          markChanges(editor, diff, type, state.marked, state.to, vp.to, classes);
          state.to = vp.to;
        }
      }
    });
  }
1330771
public void updateLayout() {

        // TODO: we should not do this kind of things...
        if (!isAttached()) {
            return;
        }
        int floatBoxWidth = getFloatBoxWidth();
        m_primary.getElement().getStyle().setMarginLeft(floatBoxWidth, Unit.PX);
        updateVerticalMargin();
    }
1287549
function () {
            var i, len, page, $page,
                width, height, left, top, paddingH,
                state = this.state,
                viewportWidth = state.viewportDimensions.clientWidth,
                viewportHeight = state.viewportDimensions.clientHeight;
            // update pages so they are centered (preserving margins)
            for (i = 0, len = this.$pages.length; i < len; ++i) {
                $page = this.$pages.eq(i);
                page = state.pages[i];

                if (this.twoPageMode) {
                    paddingH = (i % 2 === 1) ? page.paddingRight : page.paddingLeft;
                } else {
                    paddingH = page.paddingRight + page.paddingLeft;
                }
                width = (page.actualWidth + paddingH) * state.zoomState.zoom;
                height = (page.actualHeight + page.paddingTop + page.paddingBottom) * state.zoomState.zoom;

                if (this.twoPageMode) {
                    left = Math.max(0, (viewportWidth - width * 2) / 2);
                    if (i % 2 === 1) {
                        left += width;
                    }
                } else {
                    left = (viewportWidth - width) / 2;
                }
                top = (viewportHeight - height) / 2;
                left = Math.max(left, 0);
                top = Math.max(top, 0);
                $page.css({
                    marginLeft: left,
                    marginTop: top
                });
            }
        }
780645
function adjustMobilePopupDimensionAndPosition() {

				var popupHeight;
				
				//Landscape mode
				if (window.innerHeight < 400) {
					popupWidth = window.innerHeight - 60;					
					popup.css('width', popupWidth + 200 + 'px');
					inputElement.css('position', 'absolute')
								.css('left', '0px')
								.css('top', '0px')
								.css('width', '200px')
								.css('height', popupWidth + 20 + 'px');
					canvasHolder.css('margin', '10px 25px 0px 230px');
					popupHeight = popupWidth + parseInt(canvasHolder.css('margin-top')) + parseInt(canvasHolder.css('margin-bottom'));
				}
				//Normal mode (enough space for normal popup)
				else {
					popupWidth = window.innerWidth - 80;
					if (popupWidth > 300) popupWidth = 300;
					popup.css('width', popupWidth + 'px');
					inputElement.css('position', 'static')
								.css('width', '100%')
								.css('height', 'auto');
					canvasHolder.css('margin', '10px 25px 10px 25px');
					popupHeight = popupWidth + parseInt(canvasHolder.css('margin-top')) + parseInt(canvasHolder.css('margin-bottom')) + 65;
				}
				
				//Align popup in the middle of the screen				
				popup.css('left', parseInt(($('body').prop('clientWidth') - popup.outerWidth()) / 2) + 'px');
				popup.css('top', parseInt((window.innerHeight - popupHeight) / 2) + 'px');				
				
				canvasSize = popupWidth - 50;
				clockRadius = parseInt(canvasSize / 2);
				clockCenterX = parseInt(canvasSize / 2);
				clockCenterY = parseInt(canvasSize / 2);
				clockOuterRadius = clockRadius - 16;
				clockInnerRadius = clockOuterRadius - 29;
				canvasHolder.css('width', canvasSize + 'px');
				canvasHolder.css('height', canvasSize + 'px');
				clockHourCanvas.attr('width', canvasSize);
				clockHourCanvas.attr('height', canvasSize);
				clockMinuteCanvas.attr('width', canvasSize);
				clockMinuteCanvas.attr('height', canvasSize);				
			}
386365
public void updateListSize() {

        int paramsHeight = m_params.isVisible()
        ? m_params.getOffsetHeight()
            + CmsDomUtil.getCurrentStyleInt(m_params.getElement(), CmsDomUtil.Style.marginBottom)
        : 21;
        int optionsHeight = m_options.getOffsetHeight()
            + CmsDomUtil.getCurrentStyleInt(m_options.getElement(), CmsDomUtil.Style.marginBottom);
        int listTop = paramsHeight + optionsHeight + 5;
        // another sanity check, don't set any top value below 35
        if (listTop > 35) {
            m_list.getElement().getStyle().setTop(listTop, Unit.PX);
        }
    }
119382
function intersectViewportAbove([entry]) {
    updateDirection();
    const { isIntersecting, target } = entry;
    const index = getIndex(target);
    const ss = stepStates[index];

    if (
      isIntersecting &&
      direction === 'down' &&
      ss.direction !== 'down' &&
      ss.state !== 'enter'
    ) {
      notifyStepEnter(target, 'down');
      notifyStepExit(target, 'down');
    }
  }
581935
function fixPosition ( $elem, cssOffset ) {
            var visualTop = window.visualViewport ? window.visualViewport.pageTop : Math.max( dde.scrollTop, body.scrollTop ),
                visualLeft = window.visualViewport ? window.visualViewport.pageLeft : Math.max( dde.scrollLeft, body.scrollLeft );

            $elem.css( {
                top: visualTop + cssOffset.top,
                left: visualLeft + cssOffset.left
            } );
        }
1279487
private void refreshMargin() {
        if (isWeakReferenceValid()) {
            ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getTextView().get().getLayoutParams();
            layoutParams.bottomMargin = mEdgeMarginInPx;
            layoutParams.topMargin = mEdgeMarginInPx;
            layoutParams.rightMargin = mEdgeMarginInPx;
            layoutParams.leftMargin = mEdgeMarginInPx;
            getTextView().get().setLayoutParams(layoutParams);
        }
    }
398033
function () {
        if (__autoresizes == null) {
            __autoresizes = [];
            ariaUtilsAriaWindow.attachWindow();
            eventUtils.addListener(Aria.$window, "resize", {
                fn : __onResize
            });
            // PTR 08127833 - it updates the viewport sizes the first time a DOM element is registered as autoresizable
            __applyNewSize();
        }
    }
1320337
function() {
    // Lock managing state to avoid another async call. See {Function} delayedScroll.
    managing = true;

    var cells = cellsContainer.children;
    var viewportTop = (document.body.scrollTop || document.documentElement.scrollTop) - cellsContainer.offsetTop;
    var viewportBottom = (window.innerHeight || document.documentElement.clientHeight) + viewportTop;

    // Remove cells' contents if they are too far away from the viewport. Get them back if they are near.
    // TODO: remove the cells from DOM should be better :<
    for(var i = 0, l = cells.length; i < l; i++) {
      if((cells[i].offsetTop - viewportBottom > THRESHOLD) || (viewportTop - cells[i].offsetTop - cells[i].offsetHeight > THRESHOLD)) {
        if(cells[i].className === 'cell ready') {
          cells[i].fragment = cells[i].innerHTML;
          cells[i].innerHTML = '';
          cells[i].className = 'cell shadow';
        }
      } else {
        if(cells[i].className === 'cell shadow') {
          cells[i].innerHTML = cells[i].fragment;
          cells[i].className = 'cell ready';
        }
      }
    }

    // If there's space in viewport for a cell, request new cells.
    if(viewportBottom > getMinVal(columnHeights)) {
      // Remove the if/else statement in your project, just call the appendCells function.
      if(isGithubDemo) {
        appendCellsDemo(columnCount);
      } else {
        appendCells(columnCount);
      }
    }

    // Unlock managing state.
    managing = false;
  }
894737
function () {
            // Sets properties of '_features' that change on resize and/or orientation.
            var w   = win.innerWidth || _viewport.clientWidth,
                h   = win.innerHeight || _viewport.clientHeight,
                dw  = win.screen.width,
                dh  = win.screen.height,
                c   = win.screen.colorDepth,
                x   = win.devicePixelRatio;

            _features.width                     = w;
            _features.height                    = h;
            _features['aspect-ratio']           = (w / h).toFixed(2);
            _features['device-width']           = dw;
            _features['device-height']          = dh;
            _features['device-aspect-ratio']    = (dw / dh).toFixed(2);
            _features.color                     = c;
            _features['color-index']            = Math.pow(2, c);
            _features.orientation               = (h >= w ? 'portrait' : 'landscape');
            _features.resolution                = (x && x * 96) || win.screen.deviceXDPI || 96;
            _features['device-pixel-ratio']     = x || 1;
        }
624950
function updateStepAboveIO() {
    io.stepAbove = stepEl.map((el, i) => {
      const marginTop = -offsetMargin + stepOffsetHeight[i];
      const marginBottom = offsetMargin - viewH;
      const rootMargin = `${marginTop}px 0px ${marginBottom}px 0px`;
      const options = { rootMargin };
      // console.log(options);
      const obs = new IntersectionObserver(intersectStepAbove, options);
      obs.observe(el);
      return obs;
    });
  }
935481
def push_viewport(self, viewport):
        
        vp = list(viewport)
        # Normalize viewport before setting;
        if vp[2] < 0:
            vp[0] += vp[2]
            vp[2] *= -1
        if vp[3] < 0:
            vp[1] += vp[3]
            vp[3] *= -1

        self._vp_stack.append(vp)
        try:
            self.context.set_viewport(*vp)
        except:
            self._vp_stack.pop()
            raise
        
        self._update_transforms()
439398
function () {
			Crafty.viewport.pan('reset');
			Crafty.viewport.follow();
			Crafty.viewport.mouselook('stop');
			Crafty.viewport.scale();
		}
522757
function () {
            if($updateContent.length > 0 && $contentContainer.length > 0 && $updateBar.length > 0) {
                var newWidth = $updateBar.outerWidth() - 38;
                if($buttonContainer.length > 0) {
                    newWidth = newWidth- $buttonContainer.outerWidth();
                }
                if($iconContainer.length > 0) {
                    newWidth = newWidth - $iconContainer.outerWidth();
                }
                if($closeIconContainer.length > 0) {
                    newWidth = newWidth - $closeIconContainer.outerWidth();
                }

                $contentContainer.css({
                    "maxWidth": newWidth
                });
            }
        }
796749
function fixContainerSizeNow() {
               if( !showContent || !scope.isVisible ) { return; }
               let contentHeight = 0;
               jqElement.children().each( ( index, child ) => {
                  contentHeight += $( child ).outerHeight( true );
               } );
               if( contentHeight !== currentTargetHeight ) {
                  animateToHeight( jqElement, contentHeight );
                  // if this widget contains another animated widget (such as another AxShowHideWidget),
                  // make sure to pick up on its animated content
                  $window.setTimeout( fixContainerSize, RESIZE_DELAY );
               }
            }
138939
function (x, y) {
            var _x = this.pos.x;
            var _y = this.pos.y;

            this.pos.x = me.Math.clamp(
                x,
                this.bounds.pos.x,
                this.bounds.width - this.width
            );
            this.pos.y = me.Math.clamp(
                y,
                this.bounds.pos.y,
                this.bounds.height - this.height
            );

            //publish the VIEWPORT_ONCHANGE event if necessary
            if (_x !== this.pos.x || _y !== this.pos.y) {
                me.event.publish(me.event.VIEWPORT_ONCHANGE, [this.pos]);
            }
        }