diff --git a/core/wiki/macros/sidebar-resizer.tid b/core/wiki/macros/sidebar-resizer.tid index 3bdc128a0..1df2a11fe 100644 --- a/core/wiki/macros/sidebar-resizer.tid +++ b/core/wiki/macros/sidebar-resizer.tid @@ -1,14 +1,35 @@ title: $:/core/macros/sidebar-resizer +\function is.pixel.value(value) [removesuffix[px]compare:number:eq] +\function is.percentage.value(value) [removesuffix[%]compare:number:eq] \procedure sidebar-resizer-pointerdown-actions() <%if [[$:/state/sidebar/resizing]is[missing]thenmatch[left]thenmatch[normal]] %> - <$let dragGripDiff=<> storyRiverWidth={{{ [subtractsubtract[14]add[42]] }}} sidebarWidth={{{ [subtractaddadd[14]] }}}> + <$let startPosX=<> dragGripDiff=<> storyRiverWidth={{{ [subtractsubtract[14]add[42]] }}} sidebarWidth={{{ [subtractaddadd[14]] }}}> <%if [{$:/themes/tiddlywiki/vanilla/options/sidebarlayout}match[fixed-fluid]] %> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]] }}}/> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyright}] %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]] }}}/> + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyright}] %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [dividemultiply[100]addsuffix[%]] }}}/> + <% else %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]] }}}/> + <% endif %> <% else %> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [addsuffix[px]] }}}/> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth}] %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [addsuffix[px]] }}}/> + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth}] %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [dividemultiply[100]addsuffix[%]] }}}/> + <% else %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [addsuffix[px]] }}}/> + <% endif %> <% endif %> - <$action-setfield $tiddler="$:/state/sidebar/resizing" text="yes" drag-grip-diff=<>/> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] %> + <$action-setfield $tiddler="$:/state/sidebar/resizing" start-story-left={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storyleft}compare:number:gteq[0]] ~0px }}}/> + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] %> + <$action-setfield $tiddler="$:/state/sidebar/resizing" start-story-left={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storyleft}compare:number:gteq[0]] ~0% }}}/> + <% else %> + <$action-setfield $tiddler="$:/state/sidebar/resizing" start-story-left={{{ [{$:/themes/tiddlywiki/vanilla/metrics/storyleft}compare:number:gteq[0]] ~0px }}}/> + <% endif %> + <$action-setfield $tiddler="$:/state/sidebar/resizing" text="yes" drag-grip-diff=<> widget-node-width=<> start-posx=<>/> <% endif %> \end @@ -17,11 +38,58 @@ title: $:/core/macros/sidebar-resizer \end \procedure sidebar-resizer-pointermove-actions() <%if [[$:/state/sidebar/resizing]!is[missing]] %> - <$let storyRiverWidth={{{ [subtract{$:/state/sidebar/resizing!!drag-grip-diff}subtract[14]add[42]] }}} sidebarWidth={{{ [subtractadd{$:/state/sidebar/resizing!!drag-grip-diff}add[14]] }}}> - <%if [{$:/themes/tiddlywiki/vanilla/options/sidebarlayout}match[fixed-fluid]] %> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]] }}}/> + <$let dragDiff={{{ [subtract{$:/state/sidebar/resizing!!start-posx}] }}} storyRiverWidth={{{ [subtract{$:/state/sidebar/resizing!!drag-grip-diff}subtract[14]add[42]] }}} sidebarWidth={{{ [subtractadd{$:/state/sidebar/resizing!!drag-grip-diff}add[14]] }}} widgetNodeWidth={{$:/state/sidebar/resizing!!widget-node-width}}> + <%if [{$:/themes/tiddlywiki/vanilla/options/sidebarlayout}match[fixed-fluid]] %> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] %> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$vars storyLeft={{{ [{$:/state/sidebar/resizing!!start-story-left}addaddsuffix[px]] }}} storyLeftMax={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}subtract{$:/themes/tiddlywiki/vanilla/metrics/storywidth}addsuffix[px]] }}}> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyleft" text={{{ [compare:number:lteq[0]then[0px]] ~[compare:number:gteqthen] ~[] }}}/> + + <%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + + <% endif %> + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyleft}] %> + <$set name="dragDiffPercentage" value={{{ [dividemultiply[100]] }}}> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyleft" text={{{ [{$:/state/sidebar/resizing!!start-story-left}addaddsuffix[%]compare:number:gteq[0]] ~0% }}}/> + + <% else %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyleft" text={{{ [{$:/state/sidebar/resizing!!start-story-left}addaddsuffix[px]compare:number:gteq[0]] ~0px }}}/> + <% endif %> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storyright}] %> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$set name="storyRiverLimit" value={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]compare:number:lteq{$:/themes/tiddlywiki/vanilla/metrics/storywidth}then{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] [addsuffix[px]compare:number:gteqthenaddsuffix[px]] ~[addsuffix[px]] }}}/> + + <%elseif [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let sidebarMinWidth={{{ [{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}multiply[100]divide] }}} storyRiverLimit={{{ [subtract] }}}> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]compare:number:lteq{$:/themes/tiddlywiki/vanilla/metrics/storywidth}then{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] [addsuffix[px]compare:number:gteqthenaddsuffix[px]] ~[addsuffix[px]] }}}/> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} storyRiverLimit={{{ [subtract{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] }}}> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]compare:number:lteqthen] [addsuffix[px]compare:number:gteqthenaddsuffix[px]] ~[addsuffix[px]] }}}/> + + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storywidth}] +[is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}] %> + <$let storyWidthConverted={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/storywidth}divide[100]] }}} sidebarMinWidth={{{ [multiply{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}divide[100]] }}} storyRiverLimit={{{ [subtract] }}}> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]compare:number:lteqthen] [addsuffix[px]compare:number:gteqthenaddsuffix[px]] ~[addsuffix[px]] }}}/> + + <% endif %> + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/storyright}] %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [dividemultiply[100]addsuffix[%]] }}}/> + <% else %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/storyright" text={{{ [addsuffix[px]] }}}/> + <% endif %> <% else %> - <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [addsuffix[px]] }}}/> + <%if [is.pixel.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth}] %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [addsuffix[px]] }}}/> + <%elseif [is.percentage.value{$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth}] %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [dividemultiply[100]addsuffix[%]] }}}/> + <% else %> + <$action-setfield $tiddler="$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth" text={{{ [addsuffix[px]] }}}/> + <% endif %> <% endif %> <% endif %> diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 630de5eef..b02fd4f46 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -1027,7 +1027,7 @@ button.tc-btn-invisible.tc-remove-tag-button { .tc-sidebar-scrollable { position: fixed; top: {{$:/themes/tiddlywiki/vanilla/metrics/storytop}}; - left: clamp(calc({{$:/themes/tiddlywiki/vanilla/metrics/storyleft}} + {{$:/themes/tiddlywiki/vanilla/metrics/storywidth}}),{{$:/themes/tiddlywiki/vanilla/metrics/storyright}},calc(100% - {{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}})); + left: clamp({{$:/themes/tiddlywiki/vanilla/metrics/storywidth}},{{$:/themes/tiddlywiki/vanilla/metrics/storyright}},calc(100% - {{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}})); bottom: 0; right: 0; overflow-y: auto; @@ -1044,9 +1044,9 @@ button.tc-btn-invisible.tc-remove-tag-button { .tc-story-river { position: relative; - left: {{$:/themes/tiddlywiki/vanilla/metrics/storyleft}}; + left: clamp(0px,{{$:/themes/tiddlywiki/vanilla/metrics/storyleft}},calc(100% - max(calc(100% - {{$:/themes/tiddlywiki/vanilla/metrics/storyright}}),{{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}}))); top: {{$:/themes/tiddlywiki/vanilla/metrics/storytop}}; - width: clamp({{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}},calc({{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} - {{$:/themes/tiddlywiki/vanilla/metrics/storyleft}}),calc(100% - {{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}} - {{$:/themes/tiddlywiki/vanilla/metrics/storyleft}})); + width: clamp({{$:/themes/tiddlywiki/vanilla/metrics/storyminwidth}},{{$:/themes/tiddlywiki/vanilla/metrics/storywidth}},calc(100% - {{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}})); padding: 42px 42px 42px 42px; } diff --git a/themes/tiddlywiki/vanilla/sidebar-resizer.tid b/themes/tiddlywiki/vanilla/sidebar-resizer.tid index b223f2d9e..4ed186548 100644 --- a/themes/tiddlywiki/vanilla/sidebar-resizer.tid +++ b/themes/tiddlywiki/vanilla/sidebar-resizer.tid @@ -88,7 +88,7 @@ code-body: yes <%if [{$:/themes/tiddlywiki/vanilla/options/sidebarlayout}match[fixed-fluid]] %> .tc-sidebar-resizer { - left: clamp(calc({{$:/themes/tiddlywiki/vanilla/metrics/storyleft}} + {{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} - 28px),calc({{$:/themes/tiddlywiki/vanilla/metrics/storyright}} - 28px),calc(100% - {{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}} - 28px)); + left: clamp(calc({{$:/themes/tiddlywiki/vanilla/metrics/storywidth}} - 28px),calc({{$:/themes/tiddlywiki/vanilla/metrics/storyright}} - 28px),calc(100% - {{$:/themes/tiddlywiki/vanilla/metrics/sidebarminwidth}} - 28px)); } <% else %>