Skip to content

ManualConstraint

Overview

ManualConstraint exists for cases where imperative-based positioning code (e.g. node.left = otherNode.right + 5) is best for a case, and should be rerun whenever one of the nodes changes bounds.

ManualConstraint also can handle cases where the nodes do not live in the same coordinate frame (but instead with some common ancestor).

For example:

new ManualConstraint( ancestorNode, [ firstNode, secondNode ], ( firstProxy, secondProxy ) => { firstProxy.left = secondProxy.right + 5; secondProxy.centerY = firstProxy.centerY; } );

Notably in the callback, it uses LayoutProxy (which has the positional getters/setters of an object, and handles coordinate transforms).

See https://phetsims.github.io/scenery/doc/layout#ManualConstraint for details

@author Jonathan Olson <jonathan.olson@colorado.edu>

Class ManualConstraint

import { ManualConstraint } from 'scenerystack/scenery';

Constructor

new ManualConstraint( ancestorNode : Node, nodes : T, layoutCallback : LayoutCallback<T> )

Instance Methods

dispose()

Releases references

Static Methods

create( ancestorNode : Node, nodes : T, layoutCallback : LayoutCallback<T> ) : ManualConstraint<T>

Source Code

See the source for ManualConstraint.ts in the scenery repository.