Guest User

Untitled

a guest
Jul 18th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. console.log('add before: ', $(document).scrollTop());
  2. $(document).scrollTop(scrollValue);
  3. console.log('add after: ', $(document).scrollTop());
  4.  
  5.  
  6. addClassToElement(element, nameClass) {
  7. element.addClass(nameClass);
  8. }
  9.  
  10. removeClassToElement(element, nameClass) {
  11. element.removeClass(nameClass);
  12. }
  13.  
  14. fixedSearchPanel() {
  15. let resizeEvent = fromEvent(window, 'resize');
  16. let scrollEvent = fromEvent(document, 'scroll');
  17.  
  18. scrollEvent
  19. .flatMap(() => {
  20. let blockSearch = $('.search-region');
  21. let breadcrumb = $('app-breadcrumb');
  22. let tabGroup = $('.mat-list');
  23.  
  24. let scrollValue = $(document).scrollTop();
  25. if (scrollValue > 133) {
  26. let width = tabGroup.width();
  27.  
  28. if (!this.isFixedPanel) {
  29. this.addClassToElement(blockSearch, 'styles_fixed');
  30. this.addClassToElement(blockSearch, 'search_fixed');
  31. this.addClassToElement(breadcrumb, 'styles_fixed');
  32. this.addClassToElement(breadcrumb, 'breadcrumbs_fixed');
  33. blockSearch.width(width);
  34. breadcrumb.width(width);
  35.  
  36. console.log('scrollValue add: ', scrollValue);
  37.  
  38. console.log('add before: ', $(document).scrollTop());
  39. $(document).scrollTop(scrollValue);
  40. console.log('add after: ', $(document).scrollTop());
  41.  
  42. this.isFixedPanel = true;
  43. }
  44. } else {
  45. if (this.isFixedPanel) {
  46. this.removeClassToElement(blockSearch, 'styles_fixed');
  47. this.removeClassToElement(blockSearch, 'search_fixed');
  48. this.removeClassToElement(breadcrumb, 'styles_fixed');
  49. this.removeClassToElement(breadcrumb, 'breadcrumbs_fixed');
  50.  
  51. this.isFixedPanel = false;
  52. }
  53. }
  54. return resizeEvent;
  55. })
  56. .subscribe(() => {
  57. let blockSearch = $('.search-region');
  58. let breadcrumb = $('app-breadcrumb');
  59. let tabGroup = $('.mat-list');
  60.  
  61. setTimeout(() => {
  62. let width = tabGroup.width();
  63. blockSearch.width(width);
  64. breadcrumb.width(width);
  65. });
  66. });
  67. }
  68.  
  69. .styles_fixed{
  70. position: fixed;
  71. z-index: 1000;
  72. background: white;
  73. }
  74.  
  75. .breadcrumbs_fixed{
  76. padding-top: 10px;
  77. top: 0;
  78. }
  79.  
  80. .search_fixed{
  81. top: 36px;
  82. }
Add Comment
Please, Sign In to add comment