diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2020-01-21 15:32:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-21 15:32:41 +0100 |
commit | 7937ed0c20ca0df493c775e93a3294aeb5f7da26 (patch) | |
tree | 0da66ea37e4eb54741aab6f5b1dbf5fa9966fa28 /app/Resources/static/themes/material/index.js | |
parent | 996b2ec17070bb33ce9cd2ec570289565fd66306 (diff) | |
parent | dc23bf9f29b2cff5c27ee8d2d251f435d00e6652 (diff) | |
download | wallabag-7937ed0c20ca0df493c775e93a3294aeb5f7da26.tar.gz wallabag-7937ed0c20ca0df493c775e93a3294aeb5f7da26.tar.zst wallabag-7937ed0c20ca0df493c775e93a3294aeb5f7da26.zip |
Merge pull request #4255 from Simounet/feat/actions-from-sticky-btn
Feat/actions from sticky btn
Diffstat (limited to 'app/Resources/static/themes/material/index.js')
-rwxr-xr-x | app/Resources/static/themes/material/index.js | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/app/Resources/static/themes/material/index.js b/app/Resources/static/themes/material/index.js index 2926cad1..e808d75c 100755 --- a/app/Resources/static/themes/material/index.js +++ b/app/Resources/static/themes/material/index.js | |||
@@ -17,6 +17,36 @@ import './js/shortcuts/entry'; | |||
17 | /* Theme style */ | 17 | /* Theme style */ |
18 | import './css/index.scss'; | 18 | import './css/index.scss'; |
19 | 19 | ||
20 | const stickyNav = () => { | ||
21 | const nav = $('.js-entry-nav-top'); | ||
22 | $('[data-toggle="actions"]').click(() => { | ||
23 | nav.toggleClass('entry-nav-top--sticky'); | ||
24 | }); | ||
25 | }; | ||
26 | |||
27 | const articleScroll = () => { | ||
28 | const articleEl = $('#article'); | ||
29 | if (articleEl.length > 0) { | ||
30 | $(window).scroll(() => { | ||
31 | const s = $(window).scrollTop(); | ||
32 | const d = $(document).height(); | ||
33 | const c = $(window).height(); | ||
34 | const articleElBottom = articleEl.offset().top + articleEl.height(); | ||
35 | const scrollPercent = (s / (d - c)) * 100; | ||
36 | $('.progress .determinate').css('width', `${scrollPercent}%`); | ||
37 | const fixedActionBtn = $('.js-fixed-action-btn'); | ||
38 | const toggleScrollDataName = 'toggle-auto'; | ||
39 | if ((s + c) > articleElBottom) { | ||
40 | fixedActionBtn.data(toggleScrollDataName, true); | ||
41 | fixedActionBtn.openFAB(); | ||
42 | } else if (fixedActionBtn.data(toggleScrollDataName) === true) { | ||
43 | fixedActionBtn.data(toggleScrollDataName, false); | ||
44 | fixedActionBtn.closeFAB(); | ||
45 | } | ||
46 | }); | ||
47 | } | ||
48 | }; | ||
49 | |||
20 | $(document).ready(() => { | 50 | $(document).ready(() => { |
21 | // sideNav | 51 | // sideNav |
22 | $('.button-collapse').sideNav(); | 52 | $('.button-collapse').sideNav(); |
@@ -36,6 +66,8 @@ $(document).ready(() => { | |||
36 | initFilters(); | 66 | initFilters(); |
37 | initExport(); | 67 | initExport(); |
38 | initRandom(); | 68 | initRandom(); |
69 | stickyNav(); | ||
70 | articleScroll(); | ||
39 | 71 | ||
40 | const toggleNav = (toShow, toFocus) => { | 72 | const toggleNav = (toShow, toFocus) => { |
41 | $('.nav-panel-actions').hide(100); | 73 | $('.nav-panel-actions').hide(100); |
@@ -73,12 +105,4 @@ $(document).ready(() => { | |||
73 | $('.nav-panels').css('background', 'transparent'); | 105 | $('.nav-panels').css('background', 'transparent'); |
74 | return false; | 106 | return false; |
75 | }); | 107 | }); |
76 | |||
77 | $(window).scroll(() => { | ||
78 | const s = $(window).scrollTop(); | ||
79 | const d = $(document).height(); | ||
80 | const c = $(window).height(); | ||
81 | const scrollPercent = (s / (d - c)) * 100; | ||
82 | $('.progress .determinate').css('width', `${scrollPercent}%`); | ||
83 | }); | ||
84 | }); | 108 | }); |