comparison default/node_modules/shoestring/src/dom/dimension.js @ 0:1d038bc9b3d2 default tip

Up:default
author Liny <dev@neowd.com>
date Sat, 31 May 2025 09:21:51 +0800
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:1d038bc9b3d2
1 //>>excludeStart("exclude", pragmas.exclude);
2 define([ "shoestring" ], function(){
3 //>>excludeEnd("exclude");
4
5 /**
6 * Private function for setting/getting the offset property for height/width.
7 *
8 * **NOTE** Please use the [width](width.js.html) or [height](height.js.html) methods instead.
9 *
10 * @param {shoestring} set The set of elements.
11 * @param {string} name The string "height" or "width".
12 * @param {float|undefined} value The value to assign.
13 * @return shoestring
14 * @this window
15 */
16 shoestring._dimension = function( set, name, value ){
17 var offsetName;
18
19 if( value === undefined ){
20 offsetName = name.replace(/^[a-z]/, function( letter ) {
21 return letter.toUpperCase();
22 });
23
24 return set[ 0 ][ "offset" + offsetName ];
25 } else {
26 // support integer values as pixels
27 value = typeof value === "string" ? value : value + "px";
28
29 return set.each(function(){
30 this.style[ name ] = value;
31 });
32 }
33 };
34
35 //>>excludeStart("exclude", pragmas.exclude);
36 });
37 //>>excludeEnd("exclude");