Last active
August 29, 2015 14:02
-
-
Save hagino3000/4560e4be81e55749314c to your computer and use it in GitHub Desktop.
Revisions
-
hagino3000 revised this gist
Jun 3, 2014 . No changes.There are no files selected for viewing
-
Takashi Nishibayashi revised this gist
Nov 25, 2013 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,16 +22,16 @@ define([], function () { 'position': 'absolute' }); } else { // 縦長の画像の場合は横をフルに使う $img.css({ 'width': boxWidth, 'top': -1 * Math.floor(boxHeight/2 * (height/width - 1)), 'position': 'absolute' }); } return $img; } } return { createImageAdjustFn: createImageAdjustFn -
Takashi Nishibayashi revised this gist
Nov 25, 2013 . 2 changed files with 19 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,9 +5,10 @@ define(['utils', 'template'], function (Utils, JST) { // テンプレート使ってレンダリングする例 $('#target').html(JST['app/templates/fuga.ejs'], {images: [],....}); // 画像を60px * 60pxの枠に納めるとする var adjustFn = Utils.createImageAdjustFn(60, 60); $('#target .profile img').on('load', function() { // サイズを調節したい奴をセレクタで指定してloadイベントで処理する adjustFn($(this)).removeClass('need_adjust'); }); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,15 @@ define([], function () { 'use strict'; /** * 画像のサイズ調節用の関数を返す * 親のBox要素は次のスタイルを指定しておく * * - overflow: hidden * - position: relative * - width: 任意の値 * - height: 任意の値 * / function createImageAdjustFn(boxWidth, boxHeight) { return function($img) { var width = $img.width(); @@ -9,18 +18,20 @@ define([], function () { // 横長の画像の場合は縦をフルに使う $img.css({ 'height': boxHeight, 'left': -1 * Math.floor(boxWidth/2 * (width/height - 1)), 'position': 'absolute' }); } else { return $img; } } // 縦長の画像の場合は横をフルに使う $img.css({ 'width': boxWidth, 'top': -1 * Math.floor(boxHeight/2 * (height/width - 1)), 'position': 'absolute' }); } return { createImageAdjustFn: createImageAdjustFn -
Takashi Nishibayashi revised this gist
Nov 25, 2013 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,11 +6,13 @@ define([], function () { var width = $img.width(); var height = $img.height(); if (width > height) { // 横長の画像の場合は縦をフルに使う $img.css({ 'height': boxHeight, 'left': -1 * Math.floor(boxWidth/2 * (width/height - 1)) }); } else { // 縦長の画像の場合は横をフルに使う $img.css({ 'width': boxWidth, 'top': -1 * Math.floor(boxHeight/2 * (height/width - 1)) -
Takashi Nishibayashi revised this gist
Nov 25, 2013 . 2 changed files with 16 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ define(['utils', 'template'], function (Utils, JST) { 'use strict'; function render() { // テンプレート使ってレンダリングする例 $('#target').html(JST['app/templates/fuga.ejs'], {images: [],....}); // 画像を60px * 60pxの枠に納める場合 var adjustFn = Utils.createImageAdjustFn(60, 60); $('#target img').on('laod', function() { adjustFn($(this)).removeClass('need_adjust'); }); } render(); }); File renamed without changes. -
Takashi Nishibayashi revised this gist
Nov 25, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,12 +8,12 @@ define([], function () { if (width > height) { $img.css({ 'height': boxHeight, 'left': -1 * Math.floor(boxWidth/2 * (width/height - 1)) }); } else { $img.css({ 'width': boxWidth, 'top': -1 * Math.floor(boxHeight/2 * (height/width - 1)) }); } return $img; -
Takashi Nishibayashi created this gist
Nov 25, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ define([], function () { 'use strict'; function createImageAdjustFn(boxWidth, boxHeight) { return function($img) { var width = $img.width(); var height = $img.height(); if (width > height) { $img.css({ 'height': boxHeight, 'left': -1 * (Math.floor(boxWidth/2) * (width/height - 1)) }); } else { $img.css({ 'width': boxWidth, 'top': -1 * (Math.floor(boxHeight/2) * (height/width - 1)) }); } return $img; } } return { createImageAdjustFn: createImageAdjustFn } });