[Fixed Position] Keep elements in view

Prevent elements from being positioned at negative x/y
locations in a fixed position view, WTD-882.
This commit is contained in:
Victor Woeltjen
2015-02-24 11:38:46 -08:00
parent e56bac777e
commit 5ba58ef056
3 changed files with 23 additions and 6 deletions

View File

@@ -8,14 +8,26 @@ define(
/**
* Utility function for creating getter-setter functions,
* since these are frequently useful for element proxies.
*
* An optional third argument may be supplied in order to
* constrain or modify arguments when using as a setter;
* this argument is a function which takes two arguments
* (the current value for the property, and the requested
* new value.) This is useful when values need to be kept
* in certain ranges; specifically, to keep x/y positions
* non-negative in a fixed position view.
*
* @constructor
* @param {Object} object the object to get/set values upon
* @param {string} key the property to get/set
* @param {function} [updater] function used to process updates
*/
function AccessorMutator(object, key) {
function AccessorMutator(object, key, updater) {
return function (value) {
if (arguments.length > 0) {
object[key] = value;
object[key] = updater ?
updater(value, object[key]) :
value;
}
return object[key];
};