2023年政策修订增补工作正在进行中,欢迎参与!
Module:Sandbox/Dr Mince/intro/test
跳转到导航
跳转到搜索
local p = {}
local getArgs = require "Module:Arguments".getArgs
function p.main(frame)
local args = getArgs(frame,{wrapper="Template:滚动条"})
local name = args.name or ""
local root = mw.html.create("div")
:attr("id","newstyle-scroll-"..name)
local length = 0
local time = args.time or "1"
for i, v in ipairs(args) do
length = length + 1
root:tag "span"
:css("animation-delay",tonumber(time)*(i-1).."s")
:wikitext(v)
end
local totalTime = tostring(tonumber(time)*length)
local stillPercent = math.floor(100/length)
local p1 = tostring(stillPercent+8)
local p2 = tostring(stillPercent+12)
local styles = ([[
#newstyle-scroll-%s {
overflow-x: auto;
overflow-y: hidden;
text-align: %s;
white-space: nowrap;
position: relative;
height: 1.4em;
}
#newstyle-scroll-%s > span {
position: absolute;
animation: scrollDiv-%s %ss linear infinite;
-webkit-animation: scrollDiv-%s %ss linear infinite;
top: 1.5em;
}
@keyframes scrollDiv-%s {
0%% { top: 1.5em; }
8%% { top: 1.5em; }
12%% { top: 0; }
%s%% { top: 0; }
%s%% { top: -1.5em; }
100%% { top: -1.5em; }
}
@-webkit-keyframes scrollDiv-%s {
0%% { top: 1.5em; }
8%% { top: 1.5em; }
12%% { top: 0; }
%s%% { top: 0; }
%s%% { top: -1.5em; }
100%% { top: -1.5em; }
}
]]):format(name,args.align or "center",name,name,totalTime,name,totalTime,name,p1,p2,name,p1,p2) mw.log(styles)
frame:callParserFunction("#css",{styles})
mw.log(root)
return root
end
return p