Sha256: f09d45bbe1a1b9910f253d909573c0659ec8f7b40a197d7a5f8538332327b2d7
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 KB
Contents
(function() { var mutate = pageflow.react.mutate; class TimelineItemSpacer extends React.Component { constructor(props) { super(props); this.state = {}; } render() { var {TimelineItemEditorMenu} = pageflow.timelinePage; return ( <div className={this._className()}> <div className="timeline_item_spacer-inner" style={this._style()} /> <TimelineItemEditorMenu pageLink={this.props.pageLink} top={this._menuTop()} onDrag={this._handleDrag.bind(this)} onDragStop={this._handleDragStop.bind(this)}/> </div> ); } pageDidActivate() { this._measure(); } pageDidResize() { this._measure(); } _className() { return [ 'timeline_item_spacer', this._isDragging() ? 'is_dragging' : null ].join(' '); } _style() { if (this._isDragging()) { return { height: this.state.height }; } else { return { paddingTop: this.props.pageLink.top + '%' }; } } _menuTop() { if (this.state.width) { return this.state.width * (this.props.pageLink.top || 0) / 100; } return 0; } _isDragging() { return this.state && this.state.dragging; } _handleDrag(top) { this.setState({ dragging: true, height: top }); } _handleDragStop(top) { this.setState({ dragging: false }); var width = ReactDOM.findDOMNode(this).offsetWidth; mutate('updatePageLink', { id: this.props.pageLink.id, attributes: { top: top / width * 100 } }); } _measure() { this.setState({ width: ReactDOM.findDOMNode(this).offsetWidth }); } } pageflow.timelinePage.TimelineItemSpacer = pageflow.react.createPageComponent(TimelineItemSpacer); }());
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pageflow-timeline-page-0.1.0 | app/assets/javascripts/pageflow/timeline_page/components/timeline_item_spacer.jsx |