mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 17:33:23 +00:00
[Common UI] Poll split pane position
Poll to position the splitter in an mct-split-pane, in order to detect later style changes. #53.
This commit is contained in:
parent
f17410a85b
commit
861ea8bab7
@ -135,7 +135,7 @@
|
||||
{
|
||||
"key": "mctSplitPane",
|
||||
"implementation": "directives/MCTSplitPane.js",
|
||||
"depends": [ "$parse", "$log" ]
|
||||
"depends": [ "$parse", "$log", "$interval" ]
|
||||
},
|
||||
{
|
||||
"key": "mctSplitter",
|
||||
|
@ -28,6 +28,7 @@ define(
|
||||
|
||||
// Pixel width to allocate for the splitter itself
|
||||
var DEFAULT_ANCHOR = 'left',
|
||||
POLLING_INTERVAL = 15, // milliseconds
|
||||
CHILDREN_WARNING_MESSAGE = [
|
||||
"Invalid mct-split-pane contents.",
|
||||
"This element should contain exactly three",
|
||||
@ -94,7 +95,7 @@ define(
|
||||
* @memberof platform/commonUI/general
|
||||
* @constructor
|
||||
*/
|
||||
function MCTSplitPane($parse, $log) {
|
||||
function MCTSplitPane($parse, $log, $interval) {
|
||||
var anchors = {
|
||||
left: true,
|
||||
right: true,
|
||||
@ -105,6 +106,7 @@ define(
|
||||
function controller($scope, $element, $attrs) {
|
||||
var anchorKey = $attrs.anchor || DEFAULT_ANCHOR,
|
||||
anchor,
|
||||
activeInterval,
|
||||
positionParsed = $parse($attrs.position),
|
||||
position; // Start undefined, until explicitly set
|
||||
|
||||
@ -193,6 +195,16 @@ define(
|
||||
$element.children().eq(anchor.reversed ? 2 : 0)[0]
|
||||
));
|
||||
|
||||
// And poll for position changes enforced by styles
|
||||
activeInterval = $interval(function () {
|
||||
getSetPosition(getSetPosition());
|
||||
}, POLLING_INTERVAL, false);
|
||||
|
||||
// ...and stop polling when we're destroyed.
|
||||
$scope.$on('$destroy', function () {
|
||||
$interval.cancel(activeInterval);
|
||||
});
|
||||
|
||||
// Interface exposed by controller, for mct-splitter to user
|
||||
return {
|
||||
position: getSetPosition,
|
||||
|
@ -44,14 +44,11 @@ define(
|
||||
*/
|
||||
function MCTSplitter() {
|
||||
function link(scope, element, attrs, mctSplitPane) {
|
||||
var initialPosition;
|
||||
var initialPosition,
|
||||
activeInterval;
|
||||
|
||||
element.addClass("splitter");
|
||||
|
||||
// Now that we have the above class, the splitter width
|
||||
// will have changed, so trigger a positioning update.
|
||||
mctSplitPane.position(mctSplitPane.position());
|
||||
|
||||
scope.splitter = {
|
||||
// Begin moving this splitter
|
||||
startMove: function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user