打开/关闭菜单
26
6679
46
1.2万
OGAS数据中枢
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

Widget:GameSwitcher:修订间差异

来自OGAS数据中枢
弃权者留言 | 贡献
无编辑摘要
弃权者留言 | 贡献
无编辑摘要
标签手工回退
 
(未显示同一用户的5个中间版本)
第1行: 第1行:
<noinclude>
<noinclude>
本Widget为少女前线系列多游戏首页提供换交互逻辑
少女前线系列多游戏首页切换Widget。调用方式:<code><nowiki>{{#widget:GameSwitcher}}</nowiki></code>
不接受参数,直接在首页调用:<code><nowiki>{{#widget:GFHomepageSwitcher}}</nowiki></code>
</noinclude><includeonly><script>
</noinclude><includeonly><script>
( function () {
( function () {
第47行: 第46行:
   }
   }


  function moveIndicator( tab ) {
function moveIndicator( tab ) {
    var indicator = document.getElementById( 'gf-tab-indicator' );
  var indicator = document.getElementById( 'gf-tab-indicator' );
    var switcher  = document.getElementById( 'gf-switcher' );
  if ( !indicator ) { return; }
    if ( !indicator || !switcher ) { return; }
  indicator.style.width    = tab.offsetWidth + 'px';
    var sr = switcher.getBoundingClientRect();
  indicator.style.transform = 'translateX(' + tab.offsetLeft + 'px)';
    var tr = tab.getBoundingClientRect();
}
    indicator.style.width    = tr.width + 'px';
    indicator.style.transform = 'translateX(' + ( tr.left - sr.left ) + 'px)';
  }


   var currentGame = 'gf';
   var currentGame = 'gf';
   var switching  = false;
   var switching  = false;
   var pending    = null; /* { game, tabEl } */
   var pending    = null;


   function doSwitch( game, tabEl ) {
   function doSwitch( game, tabEl ) {
第69行: 第65行:
     var inSlide  = document.getElementById( 'hero-' + game );
     var inSlide  = document.getElementById( 'hero-' + game );


    /* Ken Burns重置 */
    if ( inSlide ) {
      var inFg = inSlide.querySelector( '.gf-hero-fg' );
      if ( inFg ) {
        inFg.style.transition = 'none';
        inFg.style.transform  = window.innerWidth > 1200
          ? 'translateX(-50%) scale(1.06)'
          : 'scale(1.06)';
        void inFg.offsetWidth;
        inFg.style.transition = '';
      }
    }
    /* 交叉淡入淡出 */
     if ( inSlide ) {
     if ( inSlide ) {
       inSlide.style.zIndex = '1';
       inSlide.style.zIndex = '1';
第92行: 第74行:
     }
     }


    /* tab与指示器立即响应,不等动画 */
     tabs.forEach( function ( t ) {
     tabs.forEach( function ( t ) {
       var on = t.getAttribute( 'data-game' ) === game;
       var on = t.getAttribute( 'data-game' ) === game;
第100行: 第81行:
     if ( tabEl ) { moveIndicator( tabEl ); }
     if ( tabEl ) { moveIndicator( tabEl ); }


    /* 内容面板立即切换 */
     panels.forEach( function ( p ) {
     panels.forEach( function ( p ) {
       p.classList.toggle( 'active', p.id === 'content-' + game );
       p.classList.toggle( 'active', p.id === 'content-' + game );
第111行: 第91行:
       slides.forEach( function ( s ) { s.style.zIndex = ''; } );
       slides.forEach( function ( s ) { s.style.zIndex = ''; } );
       switching = false;
       switching = false;
      /* 动画结束后执行期间积压的最后一次请求 */
       if ( pending && pending.game !== currentGame ) {
       if ( pending && pending.game !== currentGame ) {
         var p = pending;
         var p = pending;
第120行: 第98行:
         pending = null;
         pending = null;
       }
       }
     }, 720 );
     }, 520 );
   }
   }


第126行: 第104行:
     if ( game === currentGame ) { return; }
     if ( game === currentGame ) { return; }
     if ( switching ) {
     if ( switching ) {
      /* 记录最新目标,覆盖之前积压的 */
       pending = { game: game, tabEl: tabEl };
       pending = { game: game, tabEl: tabEl };
      /* 指示器和tab状态立即跟手 */
       var tabs = document.querySelectorAll( '#gf-homepage .gf-tab' );
       var tabs = document.querySelectorAll( '#gf-homepage .gf-tab' );
       tabs.forEach( function ( t ) {
       tabs.forEach( function ( t ) {

2026年6月20日 (六) 23:23的最新版本

少女前线系列多游戏首页切换Widget。调用方式:{{#widget:GameSwitcher}}