goog.math.Rect の各パラメータは x, y, w, h でアクセスできない
API Documentation ばかりを見ていたら勘違いしてしまう罠です。
console.log で Rect オブジェクトの中身を見てみると分かるのですが、goog.math.Rect(x, y, w, h) の各パラメータには left, top, width, height でアクセスできます。
var rect = new goog.math.Rect(0, 1, 2, 3); console.log(rect); // 確認用 // Bad console.log(rect.x); // undefined console.log(rect.y); // undefined console.log(rect.w); // undefined console.log(rect.h); // undefined // Good! console.log(rect.left); // x console.log(rect.top); // y console.log(rect.width); // w console.log(rect.height); // h
Closure Library とはいえ、中身は JavaScript だと実感する仕様でした。
Google API Expertが解説する Closure Libraryプログラミングガイド
- 作者: 伊藤千光
- 出版社/メーカー: インプレス
- 発売日: 2010/12/10
- メディア: 単行本(ソフトカバー)
- 購入: 4人 クリック: 183回
- この商品を含むブログ (15件) を見る