Skip to content

Commit deaad34

Browse files
author
Kevin Olson
committed
almost done with toggle offset settings
1 parent bbcb97a commit deaad34

File tree

7 files changed

+30
-20
lines changed

7 files changed

+30
-20
lines changed

media/plg_system_autoscrollspy/css/default.css

Lines changed: 6 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

media/plg_system_autoscrollspy/css/default.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

media/plg_system_autoscrollspy/css/default.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ ul.autoss-nav{
131131

132132
}
133133

134-
.autoss-float-toggle{
134+
.autoss-float-toggle.btn{
135135
position: fixed;
136136
padding: 5px;
137137
cursor: pointer;
@@ -154,6 +154,11 @@ ul.autoss-nav{
154154

155155
}
156156

157+
display: flex;
158+
align-items: center;
159+
justify-content: center;
160+
161+
157162

158163
}
159164

media/plg_system_autoscrollspy/js/autoscrollspy.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,8 @@ document.addEventListener("DOMContentLoaded", function(event) {
7878
if (floatContainer) {
7979

8080
let floatToggler = document.querySelector('.autoss-float-toggle');
81-
//calculate actual height of floatToggler from its top to its bottom
82-
let floatTogglerHeight = floatToggler.offsetHeight + parseFloat(getComputedStyle(floatToggler).marginTop) + parseFloat(getComputedStyle(floatToggler).marginBottom);
8381

84-
console.log('floatTogglerHeight is ' + floatTogglerHeight);
85-
//the top of floatToggler needs to be the top of the floatContainer minus the height of floatToggler
86-
floatToggler.style.top = (floatContainer.offsetTop - floatTogglerHeight) + 'px';
82+
floatToggler.style.top = floatPanelToggleOffsetTop;
8783

8884
const autoCollapseWidth = nav.getAttribute('data-collapsewidth');
8985
//if it's 0px, we always collapse it

plugins/system/autoscrollspy/autoscrollspy.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function onContentBeforeDisplay($context, &$article, &$params, $limitstar
4343
$plugin_path = URI::base().'plugins/system/autoscrollspy';
4444
$wam->useStyle('plg_system_autoscrollspy.default');
4545
if($enable_scrollspy == 1){
46-
$wam->useScript('plg_system_autoscrollspy.autoscrollspy');
46+
$wam->useScript('plg_system_autoscrollspy.autoscrollspy', ['defer' => true]);
4747
}
4848

4949
/* floatpanel props*/
@@ -54,11 +54,13 @@ public function onContentBeforeDisplay($context, &$article, &$params, $limitstar
5454
$floatpanel_autocollapse_width = $this->params->get('floatpanel_autocollapse_width', '768');
5555
$floatpanel_collapse_toggler_type = $this->params->get('floatpanel_collapse_toggler_type', 'fa-button');
5656
$toggletext = $this->params->get('floatpanel_collapse_toggler_text', '');
57+
$floatpanel_toggle_offset_top = $this->params->get('floatpanel_toggle_offset_top', '200px');
5758

5859
// handle offset of scroll to heading (pass to js)
5960
$scroll_offset_top = $this->params->get('scroll_offset_top', '0');
6061
$wam->addInlineScript('
6162
const scrollOffsetTop = '.$scroll_offset_top.';
63+
const floatPanelToggleOffsetTop = "'.$floatpanel_toggle_offset_top.'";
6264
', ['type' => 'text/javascript']);
6365

6466

plugins/system/autoscrollspy/autoscrollspy.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<folder>js</folder>
1717
<folder>css</folder>
1818
<folder>images</folder>
19+
<filename>joomla.asset.json</filename>
1920
</media>
2021

2122
<languages>
@@ -176,13 +177,22 @@
176177
showon="render_location:floatpanel"
177178
/>
178179
<field
180+
name="floatpanel_toggle_offset_top"
181+
type="text"
182+
label="PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_TOGGLE_OFFSET_TOP"
183+
description="PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_TOGGLE_OFFSET_TOP_DESC"
184+
default="200px"
185+
showon="render_location:floatpanel"
186+
/>
187+
<field
179188
name="floatpanel_offset_top"
180189
type="text"
181190
label="PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_OFFSET_TOP"
182191
description="PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_OFFSET_TOP_DESC"
183192
default="250px"
184193
showon="render_location:floatpanel"
185194
/>
195+
186196
<field
187197
name="floatpanel_paneltitle"
188198
type="text"

plugins/system/autoscrollspy/language/en-GB/plg_system_autoscrollspy.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_POSITION_DESC = "Where to put the panel. De
2424
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_WIDTH = "Float Panel Width (px)"
2525
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_WIDTH_DESC = "The width of the panel. Default is 200px."
2626
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_OFFSET_TOP = "Float Panel Offset Top"
27-
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_OFFSET_TOP_DESC = "How far down on the page to put this, in pixels, %, or vh. So you MUST include the px, %, or vh unit after the number for this one."
27+
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_OFFSET_TOP_DESC = "How far down the page to put the open floating menu panel. Should be HIGHER than the toggle offset top. Default is 200px."
2828
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_PANELTITLE = "Float Panel Title"
2929
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_PANELTITLE_DESC = "The title to show above a floating panel. If blank, no title is shown."
3030
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_AUTOCOLLAPSE_WIDTH = "Float Panel Auto Collapse Width (px)"
@@ -47,3 +47,5 @@ PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_COLLAPSE_TOGGLER_TEXT_DESC="The text to sho
4747
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_COLLAPSE_TOGGLER_TYPE_LOADED_SVG_ICON="Loaded Menu Icon"
4848
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_COLLAPSE_TOGGLER_TYPE_LOADED_SVG_ICON_WITH_TEXT="Loaded Menu Icon with Text"
4949

50+
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_TOGGLE_OFFSET_TOP="Toggle Offset Top"
51+
PLG_SYSTEM_AUTO_SCROLLSPY_FLOATPANEL_TOGGLE_OFFSET_TOP_DESC="Offset from top of the page to put the toggle button. Should be LESS than the panel offset top itself. Default is 200px."

0 commit comments

Comments
 (0)