RacHitodenize #RAC7889

    @@ -54,8 +54,9 @@ 'background-size': 'cover' }); $container.css({ - opacity: opacity + '%' + opacity: opacity }); + console.log(opacity); }; var loop = function () {
  • /*
     * @title RacHitodenize #RAC7889
     * @description reblog advent calend*e*r 7889 hitode909-nize
     * @include http://reblogadventcalender7889.tumblr.com/*
     * @license reblog commons license ( cc by 3.0 )
     * @require jquery
     */
    
    // bookmark:
    // http://atnd.org/events/34738
    // http://reblogadventcalender7889.tumblr.com/
    
    // http://reblogadventcalender7889.tumblr.com/post/37393584199
    // http://hitode909.hatenablog.com/entry/2012/11/17/110000
    // http://let.hatelabo.jp/hitode909/let/gYC-yuG7p7bWEg
    // made by @hitode909 https://twitter.com/hitode909
    
    window.requestAnimationFrame = (function () {
      return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (callback, element) {
        return window.setTimeout(function () {
          return callback();
        }, 1000 / 60);
      };
    })();
    
    $(function () {
      var choise = (function (list) {
        var i = 0;
        return function (list) {
          if (list.length == 0) return null;
          return list[++i % list.length];
        };
      })();
      var $body = $(document.body);
      var $container = $('#container');
    
      var $images_top = [];
      $.get('/', function (res) {
        $images_top = $(res).find('.photo img');
      });
      var opacity = 0;
    
      var step = function () {
        var $images = $('.photo img');
    
        var img = choise($images.length > 1 ? $images : $images_top);
        opacity = opacity > 0 ? 0 : 100;
    
        $body.css({
          background: img ? 'url(' + img.src + ')' : '',
          'background-position': 'center',
          'background-repeat': 'no-repeat',
          'background-attachment': 'fixed',
          'background-size': 'cover'
        });
        $container.css({
          opacity: opacity
        });
        console.log(opacity);
      };
    
      var loop = function () {
        step();
        window.requestAnimationFrame(loop);
      };
      loop();
    });
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2012/12/08 14:57:53 - 2012-12-08
  2. 2012/12/08 14:56:29 - 2012-12-08
  3. 2012/12/08 14:56:08 - 2012-12-08
  4. 2012/12/08 14:54:30 - 2012-12-08
  5. 2012/12/08 14:54:20 - 2012-12-08
  6. 2012/12/08 14:52:47 - 2012-12-08
  7. 2012/12/08 14:52:19 - 2012-12-08
  8. 2012/12/08 14:51:47 - 2012-12-08