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

Module:Sandbox/Dr Mince/intro/test

猛汉♂百科,万男皆可猛的百科全书!转载请标注来源页面的网页链接,并声明引自猛汉百科。内容不可商用。
跳到导航 跳到搜索
Template-info.svg 模块文档  [创建] [刷新]
  1. local p = {}
  2. local getArgs = require "Module:Arguments".getArgs
  3. function p.main(frame)
  4. local args = getArgs(frame,{wrapper="Template:滚动条"})
  5. local name = args.name or ""
  6. local root = mw.html.create("div")
  7. :attr("id","newstyle-scroll-"..name)
  8. local length = 0
  9. local time = args.time or "1"
  10. for i, v in ipairs(args) do
  11. length = length + 1
  12. root:tag "span"
  13. :css("animation-delay",tonumber(time)*(i-1).."s")
  14. :wikitext(v)
  15. end
  16. local totalTime = tostring(tonumber(time)*length)
  17. local stillPercent = math.floor(100/length)
  18. local p1 = tostring(stillPercent+8)
  19. local p2 = tostring(stillPercent+12)
  20. local styles = ([[
  21. #newstyle-scroll-%s {
  22. overflow-x: auto;
  23. overflow-y: hidden;
  24. text-align: %s;
  25. white-space: nowrap;
  26. position: relative;
  27. height: 1.4em;
  28. }
  29. #newstyle-scroll-%s > span {
  30. position: absolute;
  31. animation: scrollDiv-%s %ss linear infinite;
  32. -webkit-animation: scrollDiv-%s %ss linear infinite;
  33. top: 1.5em;
  34. }
  35. @keyframes scrollDiv-%s {
  36. 0%% { top: 1.5em; }
  37. 8%% { top: 1.5em; }
  38. 12%% { top: 0; }
  39. %s%% { top: 0; }
  40. %s%% { top: -1.5em; }
  41. 100%% { top: -1.5em; }
  42. }
  43. @-webkit-keyframes scrollDiv-%s {
  44. 0%% { top: 1.5em; }
  45. 8%% { top: 1.5em; }
  46. 12%% { top: 0; }
  47. %s%% { top: 0; }
  48. %s%% { top: -1.5em; }
  49. 100%% { top: -1.5em; }
  50. }
  51. ]]):format(name,args.align or "center",name,name,totalTime,name,totalTime,name,p1,p2,name,p1,p2) mw.log(styles)
  52. frame:callParserFunction("#css",{styles})
  53. mw.log(root)
  54. return root
  55. end
  56. return p