Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- console.log('add before: ', $(document).scrollTop());
- $(document).scrollTop(scrollValue);
- console.log('add after: ', $(document).scrollTop());
- addClassToElement(element, nameClass) {
- element.addClass(nameClass);
- }
- removeClassToElement(element, nameClass) {
- element.removeClass(nameClass);
- }
- fixedSearchPanel() {
- let resizeEvent = fromEvent(window, 'resize');
- let scrollEvent = fromEvent(document, 'scroll');
- scrollEvent
- .flatMap(() => {
- let blockSearch = $('.search-region');
- let breadcrumb = $('app-breadcrumb');
- let tabGroup = $('.mat-list');
- let scrollValue = $(document).scrollTop();
- if (scrollValue > 133) {
- let width = tabGroup.width();
- if (!this.isFixedPanel) {
- this.addClassToElement(blockSearch, 'styles_fixed');
- this.addClassToElement(blockSearch, 'search_fixed');
- this.addClassToElement(breadcrumb, 'styles_fixed');
- this.addClassToElement(breadcrumb, 'breadcrumbs_fixed');
- blockSearch.width(width);
- breadcrumb.width(width);
- console.log('scrollValue add: ', scrollValue);
- console.log('add before: ', $(document).scrollTop());
- $(document).scrollTop(scrollValue);
- console.log('add after: ', $(document).scrollTop());
- this.isFixedPanel = true;
- }
- } else {
- if (this.isFixedPanel) {
- this.removeClassToElement(blockSearch, 'styles_fixed');
- this.removeClassToElement(blockSearch, 'search_fixed');
- this.removeClassToElement(breadcrumb, 'styles_fixed');
- this.removeClassToElement(breadcrumb, 'breadcrumbs_fixed');
- this.isFixedPanel = false;
- }
- }
- return resizeEvent;
- })
- .subscribe(() => {
- let blockSearch = $('.search-region');
- let breadcrumb = $('app-breadcrumb');
- let tabGroup = $('.mat-list');
- setTimeout(() => {
- let width = tabGroup.width();
- blockSearch.width(width);
- breadcrumb.width(width);
- });
- });
- }
- .styles_fixed{
- position: fixed;
- z-index: 1000;
- background: white;
- }
- .breadcrumbs_fixed{
- padding-top: 10px;
- top: 0;
- }
- .search_fixed{
- top: 36px;
- }
Add Comment
Please, Sign In to add comment