Here’s the TWO changes you need to make to $:/core/modules/utils/dom/modal.js
in order to add parameters for “slidein” and “slideout”:
First, replace this:
$tw.utils.setStyle(modalWrapper,[
{transform: "translateY(" + self.srcWindow.innerHeight + "px)"}
]);
with:
if (options.variables.slideout === "top") {
$tw.utils.setStyle(modalWrapper,[
{transform: "translateY(" + (-self.srcWindow.innerHeight) + "px)"}
]);
} else if (options.variables.slideout === "left") {
$tw.utils.setStyle(modalWrapper,[
{transform: "translateX(" + (-self.srcWindow.innerWidth) + "px)"}
]);
} else if (options.variables.slideout === "right") {
$tw.utils.setStyle(modalWrapper,[
{transform: "translateX(" + (self.srcWindow.innerWidth) + "px)"}
]);
} else {
$tw.utils.setStyle(modalWrapper,[
{transform: "translateY(" + (self.srcWindow.innerHeight) + "px)"}
]);
}
Next, replace this:
$tw.utils.setStyle(modalWrapper,[
{transformOrigin: "0% 0%"},
{transform: "translateY(" + (-this.srcWindow.innerHeight) + "px)"}
]);
with this:
if (options.variables.slidein === "bottom") {
$tw.utils.setStyle(modalWrapper,[
{transformOrigin: "0% 0%"},
{transform: "translateY(" + (this.srcWindow.innerHeight) + "px)"}
]);
} else if (options.variables.slidein === "left") {
$tw.utils.setStyle(modalWrapper,[
{transformOrigin: "0% 0%"},
{transform: "translateX(" + (-this.srcWindow.innerWidth) + "px)"}
]);
} else if (options.variables.slidein === "right") {
$tw.utils.setStyle(modalWrapper,[
{transformOrigin: "0% 0%"},
{transform: "translateX(" + (this.srcWindow.innerWidth) + "px)"}
]);
} else {
$tw.utils.setStyle(modalWrapper,[
{transformOrigin: "0% 0%"},
{transform: "translateY(" + (-this.srcWindow.innerHeight) + "px)"}
]);
}
Then, in your wikitext code for triggering the modal, where you write something like:
<$button> click me
<$action-setfield $tiddler="$:/temp/mymodal" subtitle="..." text="..." footer=".."/>
<$action-sendmessage $message="tm-modal" $param="$:/temp/mymodal"/>
</$button>
you would add slidein="..."
and slideout="..."
to the tm-modal
message params, using any combination of "top"
, "bottom"
, "left"
or "right"
, like this:
<$button> click me
<$action-setfield $tiddler="$:/temp/mymodal" subtitle="..." text="..." footer=".."/>
<$action-sendmessage $message="tm-modal" $param="$:/temp/mymodal"
slidein="left" slideout="top"/>
</$button>
Note: If you omit the slidein="..."
and slideout="..."
params, it uses to the existing default behavior of slidein="top"
and slideout="bottom"
That’s it. With these changes, you can now have control over the slidein/slideout directions for individual tm-modal
dialogs.
Alternatively, you could enter global values into two tiddlers: $:/config/modals/slidein
and $:/config/modals/slideout
, and then write your $action-sendmessage widget like this:
<$action-sendmessage $message="tm-modal" $param="$:/temp/mymodal"
slidein={{$:/config/modals/slidein}} slideout={{$:/config/modals/slideout}}/>
enjoy,
-e