From 646fc64b8c053b36980dc2f3716b6a1957238b03 Mon Sep 17 00:00:00 2001 From: Vitaly Baev Date: Thu, 1 Feb 2018 17:52:00 +0300 Subject: [PATCH] =?UTF-8?q?LIL-160=20-=20=D0=A4=D0=B8=D0=BA=D1=81=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D1=88=D0=B0=D0=BF=D0=BA=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B2=D1=81=D0=B5=D1=85=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/course/templates/course/lesson.html | 4 ++-- web/build/css/app.css | 9 ++++++++- web/build/js/app.js | 22 ++++++++++++++++++++++ web/src/js/modules/common.js | 22 +++++++++++++++++++++- web/src/sass/_common.sass | 9 +++++++-- 5 files changed, 60 insertions(+), 6 deletions(-) diff --git a/apps/course/templates/course/lesson.html b/apps/course/templates/course/lesson.html index 19b11558..5477ab49 100644 --- a/apps/course/templates/course/lesson.html +++ b/apps/course/templates/course/lesson.html @@ -83,7 +83,7 @@
Задавайте вопросы:
{% if user.is_authenticated %} -
+
@@ -93,7 +93,7 @@
- + {% else %}
Только зарегистрированные пользователи могут оставлять комментарии.
{% endif %} diff --git a/web/build/css/app.css b/web/build/css/app.css index 034cd0c5..3eeb742c 100755 --- a/web/build/css/app.css +++ b/web/build/css/app.css @@ -443,6 +443,7 @@ b { .container { -ms-flex: 1 0 auto; flex: 1 0 auto; + margin-top: 100px; } .center { @@ -698,10 +699,16 @@ a.btn { } .header { - position: relative; + position: fixed; + left: 0; + right: 0; z-index: 20; } +.header--shadow { + box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.08); +} + .header__container { display: -ms-flexbox; display: flex; diff --git a/web/build/js/app.js b/web/build/js/app.js index 80c7e71c..08b1670a 100644 --- a/web/build/js/app.js +++ b/web/build/js/app.js @@ -26879,8 +26879,30 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de '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 */ /***/ (function(module, exports, __webpack_require__) { diff --git a/web/src/js/modules/common.js b/web/src/js/modules/common.js index 710ef42f..b4bdbe6e 100644 --- a/web/src/js/modules/common.js +++ b/web/src/js/modules/common.js @@ -9,5 +9,25 @@ $(document).ready(function () { } }); + // Инициируем начальное состояние шапки + updateHeader(); -}); \ No newline at end of file + $(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'); + } +} \ No newline at end of file diff --git a/web/src/sass/_common.sass b/web/src/sass/_common.sass index 56b56097..38c240d3 100755 --- a/web/src/sass/_common.sass +++ b/web/src/sass/_common.sass @@ -81,6 +81,7 @@ b .container flex: 1 0 auto + margin-top: 100px .center width: 100% @@ -278,8 +279,12 @@ a.btn width: 100% .header - position: relative - z-index: 20 + position: fixed + left: 0 + right: 0 + z-index: 20 + &--shadow + box-shadow: 0 2px 4px 0 rgba(0, 0, 0, .08) &__container display: flex height: 100px