$(function() { var date,hours,minutes,seconds; function time(){ date = new Date(); hours = date.getHours(); minutes = date.getMinutes(); seconds = date.getSeconds(); $("#watch .hours").css("transform","rotate(" + (hours * 3600 + minutes * 60 + seconds) / 120 + "deg)"); $("#watch .minutes").css("transform","rotate(" + (hours * 3600 + minutes * 60 + seconds)/ 10 + "deg)"); $("#watch .seconds").css("transform","rotate(" + (hours * 3600 + minutes * 60 + seconds) * 6 + "deg)"); setTimeout(function(){ time(); },1000); } $("document").ready(function(){ time(); $("#watch").fadeIn(1000); }); var window_height = $(window).height(); var window_width = $(window).width(); var past_window_height = window_height; var past_window_width = window_width; function objects_refresh() { // $("#stage > h1").box2d({ // 'static': true // }); $("#stage > ul > li.object_box").box2d({ 'x-velocity': 0, 'y-velocity': 0, 'angularDamping': 10, //custom: 角度変化の減衰率 'linearDamping': 10, //custom: 移動速度の減衰率 'density': 1, 'restitution': 0.1, 'friction': 0.2, 'shape': 'box', 'static': false }); $("#stage > ul > li.object_circle").box2d({ 'x-velocity': 0, 'y-velocity': 0, 'angularDamping': 10, //custom: 角度変化の減衰率 'linearDamping': 10, //custom: 移動速度の減衰率 'density': 1, 'restitution': 0.1, 'friction': 0.2, 'shape': 'circle', 'static': false }); $(document).on("touchstart touchmove touchend", function (eo) { var eo = eo.originalEvent; var touch_length = eo.touches.length; if( touch_length >= 2 ){ $(".box2d").unbind(); }else{ } }); } function objects_shuffle() { if( window_width < 500 ){ var margin = 50; }else{ var margin = 100; } var shuffle_height = window_height - margin*2; var shuffle_width = window_width - margin*2; var objects = $("#stage").find(".object_box, .object_circle"); objects.each(function(i){ var top = margin + Math.floor(Math.random()*(shuffle_height - $(this).height())); var left = margin + Math.floor(Math.random()*(shuffle_width - $(this).width())); $(this).css({ "z-index": i }); $(this).delay(25 * i).animate({ "top": top, "left": left, "opacity": 1 }, 1000, "easeOutQuint") }); $.when(objects).done(function () { objects_refresh(); $("#watch").fadeIn(1000); $("#switch").fadeIn(1000); setTimeout(function(){ $("body > li.object").removeClass("inactive"); },1); }); } function window_resize() { window_height = $(window).height(); window_width = $(window).width(); setTimeout(function(){ if( (past_window_height - window_height) > 10 || (past_window_width - window_width) > 10 || (past_window_height - window_height) < -10 || (past_window_width - window_width) < -10 ){ past_window_height = window_height; past_window_width = window_width; location.reload(); } },6000); } window.onload = function() { objects_shuffle(); } $(window).bind("resize", window_resize); function htmlEncode(value){ return $('
').text(value).html(); } function htmlDecode(value){ return $('
').html(value).text(); } });