LIL-160 - Фиксация шапки на всех страницах

remotes/origin/hasaccess
Vitaly Baev 8 years ago
parent d87a7e0c76
commit 646fc64b8c
  1. 4
      apps/course/templates/course/lesson.html
  2. 9
      web/build/css/app.css
  3. 22
      web/build/js/app.js
  4. 22
      web/src/js/modules/common.js
  5. 9
      web/src/sass/_common.sass

@ -83,7 +83,7 @@
<div class="title">Задавайте вопросы:</div> <div class="title">Задавайте вопросы:</div>
<div class="questions"> <div class="questions">
{% if user.is_authenticated %} {% if user.is_authenticated %}
<div class="questions__form"> <form class="questions__form" method="post" action="{% url 'lessoncomment' lesson_id=lesson.id %}">
<div class="questions__ava ava"> <div class="questions__ava ava">
<img class="ava__pic" src="{% static 'img/user.jpg' %}"> <img class="ava__pic" src="{% static 'img/user.jpg' %}">
</div> </div>
@ -93,7 +93,7 @@
</div> </div>
<button class="questions__btn btn btn_light">ОТПРАВИТЬ</button> <button class="questions__btn btn btn_light">ОТПРАВИТЬ</button>
</div> </div>
</div> </form>
{% else %} {% else %}
<div>Только зарегистрированные пользователи могут оставлять комментарии.</div> <div>Только зарегистрированные пользователи могут оставлять комментарии.</div>
{% endif %} {% endif %}

@ -443,6 +443,7 @@ b {
.container { .container {
-ms-flex: 1 0 auto; -ms-flex: 1 0 auto;
flex: 1 0 auto; flex: 1 0 auto;
margin-top: 100px;
} }
.center { .center {
@ -698,10 +699,16 @@ a.btn {
} }
.header { .header {
position: relative; position: fixed;
left: 0;
right: 0;
z-index: 20; z-index: 20;
} }
.header--shadow {
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.08);
}
.header__container { .header__container {
display: -ms-flexbox; display: -ms-flexbox;
display: flex; display: flex;

@ -26879,8 +26879,30 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
'X-CSRFToken': (0, _jquery2.default)('meta[name="csrf-token"]').attr('content') 'X-CSRFToken': (0, _jquery2.default)('meta[name="csrf-token"]').attr('content')
} }
}); });
// Инициируем начальное состояние шапки
updateHeader();
(0, _jquery2.default)(window).on('scroll', function () {
updateHeader();
});
}); });
function updateHeader() {
var scrollOffset = (0, _jquery2.default)(window).scrollTop();
var headerElement = (0, _jquery2.default)('header');
if (scrollOffset >= 130) {
headerElement.css('background-color', '#fff');
} else {
headerElement.css('background-color', 'rgba(255, 255, 255, ' + scrollOffset / 130 + ')');
}
if (scrollOffset >= 150) {
headerElement.addClass('header--shadow');
} else {
headerElement.removeClass('header--shadow');
}
}
/***/ }), /***/ }),
/* 128 */ /* 128 */
/***/ (function(module, exports, __webpack_require__) { /***/ (function(module, exports, __webpack_require__) {

@ -9,5 +9,25 @@ $(document).ready(function () {
} }
}); });
// Инициируем начальное состояние шапки
updateHeader();
}); $(window).on('scroll', function () {
updateHeader();
});
});
function updateHeader() {
const scrollOffset = $(window).scrollTop();
const headerElement = $('header');
if (scrollOffset >= 130) {
headerElement.css('background-color', '#fff');
} else {
headerElement.css('background-color', `rgba(255, 255, 255, ${scrollOffset / 130})`);
}
if (scrollOffset >= 150) {
headerElement.addClass('header--shadow');
} else {
headerElement.removeClass('header--shadow');
}
}

@ -81,6 +81,7 @@ b
.container .container
flex: 1 0 auto flex: 1 0 auto
margin-top: 100px
.center .center
width: 100% width: 100%
@ -278,8 +279,12 @@ a.btn
width: 100% width: 100%
.header .header
position: relative position: fixed
z-index: 20 left: 0
right: 0
z-index: 20
&--shadow
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .08)
&__container &__container
display: flex display: flex
height: 100px height: 100px

Loading…
Cancel
Save