@@ -14,13 +14,15 @@ See the License for the specific language governing permissions and
1414limitations under the License.
1515*/
1616
17- 'use strict' ;
17+ import React from 'react' ;
18+ import ReactDOM from 'react-dom' ;
19+ import sdk from 'matrix-react-sdk' ;
20+ import dis from 'matrix-react-sdk/lib/dispatcher' ;
21+ import AccessibleButton from 'matrix-react-sdk/lib/components/views/elements/AccessibleButton' ;
22+ import Velocity from 'velocity-vector' ;
23+ import 'velocity-vector/velocity.ui' ;
1824
19- var React = require ( 'react' ) ;
20- var ReactDOM = require ( 'react-dom' ) ;
21- var sdk = require ( 'matrix-react-sdk' )
22- var dis = require ( 'matrix-react-sdk/lib/dispatcher' ) ;
23- var AccessibleButton = require ( 'matrix-react-sdk/lib/components/views/elements/AccessibleButton' ) ;
25+ const CALLOUT_ANIM_DURATION = 1000 ;
2426
2527module . exports = React . createClass ( {
2628 displayName : 'BottomLeftMenu' ,
@@ -40,6 +42,18 @@ module.exports = React.createClass({
4042 } ) ;
4143 } ,
4244
45+ componentWillMount : function ( ) {
46+ this . _dispatcherRef = dis . register ( this . onAction ) ;
47+ this . _peopleButton = null ;
48+ this . _directoryButton = null ;
49+ this . _createRoomButton = null ;
50+ this . _lastCallouts = { } ;
51+ } ,
52+
53+ componentWillUnmount : function ( ) {
54+ dis . unregister ( this . _dispatcherRef ) ;
55+ } ,
56+
4357 // Room events
4458 onDirectoryClick : function ( ) {
4559 dis . dispatch ( { action : 'view_room_directory' } ) ;
@@ -104,6 +118,30 @@ module.exports = React.createClass({
104118 this . setState ( { settingsHover : false } ) ;
105119 } ,
106120
121+ onAction : function ( payload ) {
122+ let calloutElement ;
123+ switch ( payload . action ) {
124+ // Incoming instruction: dance!
125+ case 'callout_start_chat' :
126+ calloutElement = this . _peopleButton ;
127+ break ;
128+ case 'callout_room_directory' :
129+ calloutElement = this . _directoryButton ;
130+ break ;
131+ case 'callout_create_room' :
132+ calloutElement = this . _createRoomButton ;
133+ break ;
134+ }
135+ if ( calloutElement ) {
136+ const lastCallout = this . _lastCallouts [ payload . action ] ;
137+ const now = Date . now ( ) ;
138+ if ( lastCallout == undefined || lastCallout < now - CALLOUT_ANIM_DURATION ) {
139+ this . _lastCallouts [ payload . action ] = now ;
140+ Velocity ( ReactDOM . findDOMNode ( calloutElement ) , "callout.bounce" , CALLOUT_ANIM_DURATION ) ;
141+ }
142+ }
143+ } ,
144+
107145 // Get the label/tooltip to show
108146 getLabel : function ( label , show ) {
109147 if ( show ) {
@@ -112,6 +150,18 @@ module.exports = React.createClass({
112150 }
113151 } ,
114152
153+ _collectPeopleButton : function ( e ) {
154+ this . _peopleButton = e ;
155+ } ,
156+
157+ _collectDirectoryButton : function ( e ) {
158+ this . _directoryButton = e ;
159+ } ,
160+
161+ _collectCreateRoomButton : function ( e ) {
162+ this . _createRoomButton = e ;
163+ } ,
164+
115165 render : function ( ) {
116166 var TintableSvg = sdk . getComponent ( 'elements.TintableSvg' ) ;
117167
@@ -130,15 +180,15 @@ module.exports = React.createClass({
130180 < div className = "mx_BottomLeftMenu_options" >
131181 { homeButton }
132182 < AccessibleButton className = "mx_BottomLeftMenu_people" onClick = { this . onPeopleClick } onMouseEnter = { this . onPeopleMouseEnter } onMouseLeave = { this . onPeopleMouseLeave } >
133- < TintableSvg src = "img/icons-people.svg" width = "25" height = "25" />
183+ < TintableSvg ref = { this . _collectPeopleButton } src = "img/icons-people.svg" width = "25" height = "25" />
134184 { this . getLabel ( "Start chat" , this . state . peopleHover ) }
135185 </ AccessibleButton >
136186 < AccessibleButton className = "mx_BottomLeftMenu_directory" onClick = { this . onDirectoryClick } onMouseEnter = { this . onDirectoryMouseEnter } onMouseLeave = { this . onDirectoryMouseLeave } >
137- < TintableSvg src = "img/icons-directory.svg" width = "25" height = "25" />
187+ < TintableSvg ref = { this . _collectDirectoryButton } src = "img/icons-directory.svg" width = "25" height = "25" />
138188 { this . getLabel ( "Room directory" , this . state . directoryHover ) }
139189 </ AccessibleButton >
140190 < AccessibleButton className = "mx_BottomLeftMenu_createRoom" onClick = { this . onRoomsClick } onMouseEnter = { this . onRoomsMouseEnter } onMouseLeave = { this . onRoomsMouseLeave } >
141- < TintableSvg src = "img/icons-create-room.svg" width = "25" height = "25" />
191+ < TintableSvg ref = { this . _collectCreateRoomButton } src = "img/icons-create-room.svg" width = "25" height = "25" />
142192 { this . getLabel ( "Create new room" , this . state . roomsHover ) }
143193 </ AccessibleButton >
144194 < AccessibleButton className = "mx_BottomLeftMenu_settings" onClick = { this . onSettingsClick } onMouseEnter = { this . onSettingsMouseEnter } onMouseLeave = { this . onSettingsMouseLeave } >
0 commit comments