Scroll down to see the effect
Element to be positioned under test element
Test element to sync with.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
import angular from 'angular'; import '@jetbrains/ring-ui/components/place-under-ng/place-under-ng'; import {getDocumentScrollTop} from '@jetbrains/ring-ui/components/global/dom'; window.addEventListener('scroll', function () { var target = document.querySelector('.target-element'); var scrolledTop = getDocumentScrollTop(); if (scrolledTop > 30) { target.style.position = 'fixed'; } else { target.style.position = 'static'; } }); @value unit from '../global/global.css'; :global(.place-under) { position: fixed; top: 0; right: 0; width: 50%; padding: calc(unit * 2); background-color: #888; } :global(.head) { height: 30px; } :global(.target-element) { position: static; top: 0; width: 100%; padding: calc(unit * 2); background-color: #CCC; } :global(.scrollable) { height: 1000px; padding: calc(unit * 2); padding-top: calc(unit * 8); background-color: #EEE; }