MCPcopy
hub / github.com/bendc/sprint / getSetDimension

Function getSetDimension

sprint.js:158–188  ·  view source on GitHub ↗
(obj, prop, value)

Source from the content-addressed store, hash-verified

156 }
157
158 var getSetDimension = function(obj, prop, value) {
159 // get
160 if (value == null) {
161 var el = obj.get(0)
162 if (!el || el.nodeType > 1) return
163 var capitalizedProp = prop[0].toUpperCase() + prop.substring(1)
164 // dimension of HTML document
165 if (el == document) {
166 var offset = root["offset" + capitalizedProp]
167 var inner = window["inner" + capitalizedProp]
168 return offset > inner ? offset : inner
169 }
170 // dimension of viewport
171 if (el == window) {
172 return window["inner" + capitalizedProp]
173 }
174 // dimension of element
175 return el.getBoundingClientRect()[prop]
176 }
177
178 // set
179 var isFunction = typeof value == "function"
180 var stringValue = isFunction ? "" : addPx(prop, value)
181 return obj.each(function(index) {
182 if (this == document || this == window || this.nodeType > 1) return
183 if (isFunction) {
184 stringValue = addPx(prop, value.call(this, index, Sprint(this)[prop]()))
185 }
186 this.style[prop] = stringValue
187 })
188 }
189
190 var insertHTML = function(position, args) {
191 var argsLen = args.length

Callers 1

sprint.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected