2014-10-09 2 views
0

GridLayout에있는 서페이스에 StateModifier를 부착하려면 어떻게해야합니까?famo.us StateModifier가있는 GridLayout의 서페이스 상태를 애니메이션으로 표현합니다.

//... 
var grid = new Gridlayout({dimensions: [2,1]}); 

var surfaces = []; 
grid.sequenceFrom(surfaces); 

var surface01 = new Surface({content: 'Surface 01'}); 
var surface02 = new Surface({content: 'Surface 02'}); 

surfaces.push(surface01,surface02); 

this._node.add(grid); 
//... 

표면이 같은 명시 적으로 렌더링 트리에 추가되지 않기 때문에 : 나는이에 수정을 첨부 할 수 있습니다 방법을 모르는

내 코드는 다음과 같이 보입니다 표면?! 내가 놓친 게 있니? 어떤 도움을 많이 주신 경우

답변

0

항목에서보기로보기를 추가해야합니다. 예제 코드는 아래의보기 항목으로 RenderNode를 사용하고 StateModifierSurface

Example jsBin Code [Famo.us의 v0.3.0]

var mainContext = Engine.createContext(); 

    var surfaces = []; 
    var grid = new GridLayout({ 
    dimensions: [2, 1] 
    }); 

    var counter = 0; 

    _getView = function(name) { 
    var rnode = new RenderNode(); 
    var state = new StateModifier({ 
     size: [undefined, 500] 
    }); 
    var surface = new Surface({ 
     content:name, 
     properties: { 
     backgroundColor: "hsl(" + (counter * 360/8) + ", 100%, 50%)", 
     lineHeight: '500px', 
     textAlign: 'center', 
     cursor: 'pointer' 
     } 
    }); 
    rnode.add(state).add(surface); 
    counter += 1; 
    return rnode; 
    }; 

    surfaces.push(_getView('Surface 1')); 

    surfaces.push(_getView('Surface 2')); 

    grid.sequenceFrom(surfaces); 

    mainContext.add(grid); 
+0

무엇 Talves이 말하고있는 것은 :에 표면을 추가하지 마십시오 그리드에 모디파이어 (각 표면이 포함 된)를 추가하십시오. (: – trusktr

+1

이 경우 렌더러 배열의 서페이스에만 국한되지 않습니다. 또 다른 점은이 렌더러 배열이 ViewSequence로 변환된다는 것입니다. 또한 ViewSequence를'sequenceFrom' 함수에 전달할 수도 있습니다. – talves

+0

그래, 너 기본적으로 모든 장면 그래프 트리를 그리드에 추가 할 수 있습니다. – trusktr

0

난 아무것도없는 아니에요 경우 원하는 추가 그 중 하나를 클릭하여 gridLayout 내부에서 서페이스의 상태를 수정 하시겠습니까 ?? GridLayout과는 gridlayout._states에게 [ '당신의 표면의 인덱스를']를 입력하여 액세스 할 수있는 상태의 배열을 가지고

var mainContext = Engine.createContext(); 
 

 
var surfaces = []; 
 

 
var GridLayout = new GridLayout({ 
 
    dimensions: [4,10] 
 
    }); 
 

 
for (var i = 0; i<40; i++){ 
 
    
 
    var surface = new Surface({ 
 
    content: 'surface' + i, 
 
    size: [200, 200] 
 
    }); 
 
    
 
    surface.index = i; 
 
    
 
    surfaces.push(surface); 
 
    }); 
 

 
GridLayout.sequenceFrom(surfaces); 
 

 
//now if you want to modify the state of the surface with index 2 
 
GridLayout._states[2].set(Transform.rotateX(Math.PI/2)); // your surface will rotate by 90° on X axis 
 

 
mainContext.add(GridLayout);

기본적으로
+0

GridLayout._modifiers []를 사용하여 수정 자에 액세스 할 수 있지만 전환 가능을 직접 관리하는 것이 좋습니다. – Duduche

관련 문제