置顶公告:【置顶】关于临时开启评论区所有功能的公告(2022.10.22) | 【置顶】关于本站Widget恢复使用的公告
  • 你好~!欢迎来到萌娘百科镜像站!如需查看或编辑,请联系本站管理员注册账号。
  • 本镜像站和其他萌娘百科的镜像站无关,请注意分别。

Module:Sandbox/Dr Mince/intro/test

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [创建] [刷新]
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