4 * Copyright 2016 RIFT.IO Inc
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 * Created by onvelocity on 8/11/15.
22 import alt
from '../alt';
23 import changeCase
from 'change-case'
26 This class manages Composer Layout State
29 const cleanNameRegExp
= /(-is-tray-open|panel-)/i;
31 class PanelResizeAction
{
35 /* we expect two types of resize events:
36 * window resize - invoked by window
37 * resize-manager resize - invoked by ResizeManager
39 * normalize the data needed by the Composer Layout or ignore invalid ones
47 if (e
.detail
&& e
.detail
.side
) {
48 // a ResizeManager event
49 this.dispatch(PanelResizeAction
.buildResizeManagerInfo(e
))
52 this.dispatch(PanelResizeAction
.buildWindowResizeInfo(e
));
57 static buildWindowResizeInfo(e
) {
61 static buildResizeManagerInfo(e
) {
62 const info
= Object
.assign({originalEvent
: e
}, e
.detail
);
63 const name
= changeCase
.paramCase(info
.target
.className
.replace(cleanNameRegExp
, ''));
64 info
.type
= 'resize-manager.resize.' + name
;
70 export default alt
.createActions(PanelResizeAction
);